Example #1
0
    def get_file(self):
        preserve_extension = self.request.GET.get(
            'preserve_extension',
            self.request.POST.get('preserve_extension', False))

        preserve_extension = preserve_extension == 'true' or preserve_extension == 'True'

        instance = self.get_object()
        return VirtualFile(instance.file,
                           name=instance.get_rendered_string(
                               preserve_extension=preserve_extension))
Example #2
0
 def get_file_ZIP(self):
     bytes_io = BytesIO()
     zf = zipfile.ZipFile(bytes_io, "w")
     zip_subdir = "inobi"
     zip_filename = "%s.zip" % zip_subdir
     for value in range(0, 9):
         _ , fname = os.path.split(self.photo.image.url)
         zip_path = os.path.join(zip_subdir, "%s_%s" % (value, fname))
         new_image = self.get_resize_image()
         io_bytes = BytesIO()
         new_image.save(io_bytes, 'PNG')
         zf.writestr(zip_path, data=io_bytes.getvalue())
     zf.close()
     return VirtualFile(bytes_io, name=zip_filename)
Example #3
0
 def get_file(self):
     """Return wrapper on ``StringIteratorIO`` object."""
     file_obj = TextIteratorIO(generate_hello())
     return VirtualFile(file_obj, name='hello-world.txt')
Example #4
0
 def get_file(self):
     """Return wrapper on ``six.StringIO`` object."""
     file_obj = StringIO(u"Hello world!\n")
     return VirtualFile(file_obj, name='hello-world.txt')
Example #5
0
 def get_file(self):
     instance = self.get_object()
     return VirtualFile(instance.latest_version.file, name=instance.label)
Example #6
0
 def get_file(self):
     instance = self.get_object()
     return VirtualFile(instance.file, name=force_text(instance))
Example #7
0
 def get_file(self):
     instance = self.get_object()
     return VirtualFile(instance.file, name=unicode(instance))
Example #8
0
 def get_file_IMAGE(self):
     _, fname = os.path.split(self.photo.image.url)
     new_image = self.get_resize_image()
     bytes_io = BytesIO()
     new_image.save(bytes_io, 'PNG')
     return VirtualFile(bytes_io, name=fname)