Exemplo n.º 1
0
 def open(self):
     if self.file.startswith('http'):
         return requests.get(self.file, stream=True).raw
     elif self.file.startswith(r'data:image/'):
         return BytesIO(
             base64.b64decode(
                 self.file.replace('data:image/jpeg;base64,', '')))
     return get_storage_backend().open(self.file)
Exemplo n.º 2
0
 def test_get_storage_backend(self):
     if has_django():
         self.assertIsInstance(get_storage_backend(), DjangoStorageBackend)
     else:
         self.assertIsInstance(get_storage_backend(),
                               FilesystemStorageBackend)
Exemplo n.º 3
0
 def save_alternative_resolution(self, resolution, image, options):
     path = self.alternative_resolution_path(resolution)
     return get_storage_backend().save(
         path,
         get_engine().raw_data(image, options))
Exemplo n.º 4
0
 def exists(self):
     return get_storage_backend().exists(self.path)
Exemplo n.º 5
0
 def save(self, options):
     return get_storage_backend().save(
         self.path,
         get_engine().raw_data(self.image, options))
Exemplo n.º 6
0
 def open(self):
     if self.file.startswith('http'):
         return requests.get(self.file, stream=True).raw
     elif self.file.startswith(r'data:image/'):
         return BytesIO(base64.b64decode(self.file.replace('data:image/jpeg;base64,', '')))
     return get_storage_backend().open(self.file)
Exemplo n.º 7
0
 def save_alternative_resolution(self, resolution, image, options):
     path = self.alternative_resolution_path(resolution)
     return get_storage_backend().save(path, get_engine().raw_data(image, options))
Exemplo n.º 8
0
 def save(self, options):
     return get_storage_backend().save(self.path, get_engine().raw_data(self.image, options))
Exemplo n.º 9
0
 def exists(self):
     return get_storage_backend().exists(self.path)
Exemplo n.º 10
0
 def test_get_storage_backend(self):
     if has_django():
         self.assertIsInstance(get_storage_backend(), DjangoStorageBackend)
     else:
         self.assertIsInstance(get_storage_backend(), FilesystemStorageBackend)