本文整理匯總了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)