Exemplo n.º 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))
Exemplo n.º 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)
Exemplo n.º 3
0
 def get_file(self):
     """Return wrapper on ``StringIteratorIO`` object."""
     file_obj = TextIteratorIO(generate_hello())
     return VirtualFile(file_obj, name='hello-world.txt')
Exemplo n.º 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')
Exemplo n.º 5
0
 def get_file(self):
     instance = self.get_object()
     return VirtualFile(instance.latest_version.file, name=instance.label)
Exemplo n.º 6
0
 def get_file(self):
     instance = self.get_object()
     return VirtualFile(instance.file, name=force_text(instance))
Exemplo n.º 7
0
 def get_file(self):
     instance = self.get_object()
     return VirtualFile(instance.file, name=unicode(instance))
Exemplo n.º 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)