Exemple #1
0
 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
Exemple #2
0
 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
Exemple #3
0
 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
Exemple #4
0
 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)
Exemple #5
0
 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)