当前位置: 首页>>代码示例>>Python>>正文


Python InMemoryUploadedFile.DEFAULT_CHUNK_SIZE方法代码示例

本文整理汇总了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)
开发者ID:dcosson,项目名称:django-thumbs,代码行数:22,代码来源:thumbs.py


注:本文中的django.core.files.uploadedfile.InMemoryUploadedFile.DEFAULT_CHUNK_SIZE方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。