本文整理汇总了Python中corehq.apps.hqmedia.models.CommCareImage.get_thumbnail_data方法的典型用法代码示例。如果您正苦于以下问题:Python CommCareImage.get_thumbnail_data方法的具体用法?Python CommCareImage.get_thumbnail_data怎么用?Python CommCareImage.get_thumbnail_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corehq.apps.hqmedia.models.CommCareImage
的用法示例。
在下文中一共展示了CommCareImage.get_thumbnail_data方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from corehq.apps.hqmedia.models import CommCareImage [as 别名]
# 或者: from corehq.apps.hqmedia.models.CommCareImage import get_thumbnail_data [as 别名]
def get(self, request, *args, **kwargs):
data, content_type = self.multimedia.get_display_file()
if self.thumb:
data = CommCareImage.get_thumbnail_data(data, self.thumb)
response = HttpResponse(mimetype=content_type)
response.write(data)
return response
示例2: get
# 需要导入模块: from corehq.apps.hqmedia.models import CommCareImage [as 别名]
# 或者: from corehq.apps.hqmedia.models.CommCareImage import get_thumbnail_data [as 别名]
def get(self, request, *args, **kwargs):
data, content_type = self.multimedia.get_display_file()
if self.thumb:
data = CommCareImage.get_thumbnail_data(data, self.thumb)
response = HttpResponse(data, content_type=content_type)
response['Content-Disposition'] = 'filename="download{}"'.format(self.multimedia.get_file_extension())
return response
示例3: get
# 需要导入模块: from corehq.apps.hqmedia.models import CommCareImage [as 别名]
# 或者: from corehq.apps.hqmedia.models.CommCareImage import get_thumbnail_data [as 别名]
def get(self, request, *args, **kwargs):
obj = CachedObject(str(self.doc_id) + ':' + self.kwargs.get('media_type'))
if not obj.is_cached():
data, content_type = self.multimedia.get_display_file()
if self.thumb:
data = CommCareImage.get_thumbnail_data(data, self.thumb)
buffer = StringIO(data)
metadata = {'content_type': content_type}
obj.cache_put(buffer, metadata, timeout=0)
else:
metadata, buffer = obj.get()
data = buffer.getvalue()
content_type = metadata['content_type']
return HttpResponse(data, mimetype=content_type)