本文整理汇总了Python中django.core.files.uploadedfile.InMemoryUploadedFile.DEFAULT_CHUNK_SIZE方法的典型用法代码示例。如果您正苦于以下问题:Python InMemoryUploadedFile.DEFAULT_CHUNK_SIZE方法的具体用法?Python InMemoryUploadedFile.DEFAULT_CHUNK_SIZE怎么用?Python InMemoryUploadedFile.DEFAULT_CHUNK_SIZE使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.core.files.uploadedfile.InMemoryUploadedFile
的用法示例。
在下文中一共展示了InMemoryUploadedFile.DEFAULT_CHUNK_SIZE方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: regenerate_thumbs
# 需要导入模块: from django.core.files.uploadedfile import InMemoryUploadedFile [as 别名]
# 或者: from django.core.files.uploadedfile.InMemoryUploadedFile import DEFAULT_CHUNK_SIZE [as 别名]
def regenerate_thumbs(self):
# -- Delete existing thumbs and resized images
# Note: (if you have changed the sizes, it won't know to delete the thumbs of the old sizes. # call _delete_thumbs before changing size to clean those up
self._delete_thumbs()
# -- Create new thumbs and resized images
img = Image.open(self)
img.seek(0) # you would think it's already at the beginning, but everyone else is doing it
# set image format:
format = self.name.rsplit(".", 1)[1]
if format.upper() == "JPG":
format = "JPEG"
# Load into memory for PIL to use
size = settings.FILE_UPLOAD_MAX_MEMORY_SIZE
io = cStringIO.StringIO()
img.save(io, format)
io.seek(0) # here we do need it
pic = InMemoryUploadedFile(io, "", self.name, "image", size, "utf-8")
pic.DEFAULT_CHUNK_SIZE = size #otherwise biggest image it will handle is 64 kB
self._save_thumbs(pic)