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
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
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
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)
def get(self, request, *args, **kwargs): obj = CachedObject( str(self.doc_id) + ':' + self.kwargs.get('media_type') + ':' + str(self.thumb)) 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=None) else: metadata, buffer = obj.get() data = buffer.getvalue() content_type = metadata['content_type'] return HttpResponse(data, content_type=content_type)