Python django.core.files.storage.default_storage() Examples
The following are 20
code examples of django.core.files.storage.default_storage().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
django.core.files.storage
, or try the search function
.
Example #1
Source File: apps.py From django-s3file with MIT License | 6 votes |
def ready(self): from django.core.files.storage import default_storage from storages.backends.s3boto3 import S3Boto3Storage from django import forms from .forms import S3FileInputMixin if isinstance(default_storage, S3Boto3Storage) and \ S3FileInputMixin not in forms.ClearableFileInput.__bases__: forms.ClearableFileInput.__bases__ = \ (S3FileInputMixin,) + forms.ClearableFileInput.__bases__ elif S3FileInputMixin in forms.ClearableFileInput.__bases__: forms.ClearableFileInput.__bases__ = tuple( cls for cls in forms.ClearableFileInput.__bases__ if cls is not S3FileInputMixin ) checks.register(storage_check, checks.Tags.security, deploy=True)
Example #2
Source File: files.py From python with Apache License 2.0 | 5 votes |
def __init__(self, verbose_name=None, name=None, upload_to='', storage=None, **kwargs): self._primary_key_set_explicitly = 'primary_key' in kwargs self.storage = storage or default_storage self.upload_to = upload_to kwargs['max_length'] = kwargs.get('max_length', 100) super(FileField, self).__init__(verbose_name, name, **kwargs)
Example #3
Source File: files.py From hypha with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self, instance, field, *args, filename=None, storage=default_storage, **kwargs): super().__init__(*args, **kwargs) # Field is the wagtail field that the file was uploaded to self.field = field # Instance is the parent model object that created this file object self.instance = instance self.storage = storage self.filename = filename or self.basename self._committed = False
Example #4
Source File: files.py From python2017 with MIT License | 5 votes |
def deconstruct(self): name, path, args, kwargs = super(FileField, self).deconstruct() if kwargs.get("max_length") == 100: del kwargs["max_length"] kwargs['upload_to'] = self.upload_to if self.storage is not default_storage: kwargs['storage'] = self.storage return name, path, args, kwargs
Example #5
Source File: files.py From python2017 with MIT License | 5 votes |
def __init__(self, verbose_name=None, name=None, upload_to='', storage=None, **kwargs): self._primary_key_set_explicitly = 'primary_key' in kwargs self.storage = storage or default_storage self.upload_to = upload_to kwargs['max_length'] = kwargs.get('max_length', 100) super(FileField, self).__init__(verbose_name, name, **kwargs)
Example #6
Source File: files.py From openhgsenti with Apache License 2.0 | 5 votes |
def deconstruct(self): name, path, args, kwargs = super(FileField, self).deconstruct() if kwargs.get("max_length") == 100: del kwargs["max_length"] kwargs['upload_to'] = self.upload_to if self.storage is not default_storage: kwargs['storage'] = self.storage return name, path, args, kwargs
Example #7
Source File: files.py From openhgsenti with Apache License 2.0 | 5 votes |
def __init__(self, verbose_name=None, name=None, upload_to='', storage=None, **kwargs): self._primary_key_set_explicitly = 'primary_key' in kwargs self._unique_set_explicitly = 'unique' in kwargs self.storage = storage or default_storage self.upload_to = upload_to kwargs['max_length'] = kwargs.get('max_length', 100) super(FileField, self).__init__(verbose_name, name, **kwargs)
Example #8
Source File: __init__.py From django-estimators with MIT License | 5 votes |
def get_storage(): ''' return configured Storage ''' return default_storage # for default filesystem, (location=settings.MEDIA_ROOT)
Example #9
Source File: checks.py From django-s3file with MIT License | 5 votes |
def storage_check(app_configs, **kwargs): if isinstance(default_storage, FileSystemStorage): return [ Error( 'FileSystemStorage should not be used in a production environment.', hint='Please verify your DEFAULT_FILE_STORAGE setting.', id='s3file.E001', ) ] return []
Example #10
Source File: files.py From python with Apache License 2.0 | 5 votes |
def deconstruct(self): name, path, args, kwargs = super(FileField, self).deconstruct() if kwargs.get("max_length") == 100: del kwargs["max_length"] kwargs['upload_to'] = self.upload_to if self.storage is not default_storage: kwargs['storage'] = self.storage return name, path, args, kwargs
Example #11
Source File: files.py From GTDWeb with GNU General Public License v2.0 | 5 votes |
def __init__(self, verbose_name=None, name=None, upload_to='', storage=None, **kwargs): self._primary_key_set_explicitly = 'primary_key' in kwargs self._unique_set_explicitly = 'unique' in kwargs self.storage = storage or default_storage self.upload_to = upload_to if callable(upload_to): self.generate_filename = upload_to kwargs['max_length'] = kwargs.get('max_length', 100) super(FileField, self).__init__(verbose_name, name, **kwargs)
Example #12
Source File: files.py From Hands-On-Application-Development-with-PyCharm with MIT License | 5 votes |
def deconstruct(self): name, path, args, kwargs = super().deconstruct() if kwargs.get("max_length") == 100: del kwargs["max_length"] kwargs['upload_to'] = self.upload_to if self.storage is not default_storage: kwargs['storage'] = self.storage return name, path, args, kwargs
Example #13
Source File: files.py From Hands-On-Application-Development-with-PyCharm with MIT License | 5 votes |
def __init__(self, verbose_name=None, name=None, upload_to='', storage=None, **kwargs): self._primary_key_set_explicitly = 'primary_key' in kwargs self.storage = storage or default_storage self.upload_to = upload_to kwargs.setdefault('max_length', 100) super().__init__(verbose_name, name, **kwargs)
Example #14
Source File: file_field.py From django-localized-fields with MIT License | 5 votes |
def deconstruct(self): name, path, args, kwargs = super().deconstruct() kwargs["upload_to"] = self.upload_to if self.storage is not default_storage: kwargs["storage"] = self.storage return name, path, args, kwargs
Example #15
Source File: file_field.py From django-localized-fields with MIT License | 5 votes |
def __init__( self, verbose_name=None, name=None, upload_to="", storage=None, **kwargs ): self.storage = storage or default_storage self.upload_to = upload_to super().__init__(verbose_name, name, **kwargs)
Example #16
Source File: admin.py From django-quill with BSD 3-Clause "New" or "Revised" License | 5 votes |
def handle_upload(self, request): """Handle file uploads from WYSIWYG.""" if request.method != 'POST': raise Http404 if request.is_ajax(): try: filename = request.GET['quillUploadFile'] data = request is_raw = True except KeyError: return HttpResponseBadRequest("Invalid file upload.") else: if len(request.FILES) != 1: return HttpResponseBadRequest("Can only upload 1 file at a time.") try: data = request.FILES['quillUploadFile'] filename = data.name is_raw = False except KeyError: return HttpResponseBadRequest('Missing image `quillUploadFile`.') url = save_file(data, filename, is_raw, default_storage) response_data = {} response_data['url'] = url # Response content type needs to be text/html here or else # IE will try to download the file. return HttpResponse(json.dumps(response_data), content_type="text/html; charset=utf-8")
Example #17
Source File: tasks.py From OasisPlatform with BSD 3-Clause "New" or "Revised" License | 5 votes |
def is_in_bucket(object_key): if not hasattr(default_storage, 'bucket'): return False else: try: default_storage.bucket.Object(object_key).load() return True except S3_ClientError as e: if e.response['Error']['Code'] == "404": return False else: raise e
Example #18
Source File: files.py From bioforum with MIT License | 5 votes |
def deconstruct(self): name, path, args, kwargs = super().deconstruct() if kwargs.get("max_length") == 100: del kwargs["max_length"] kwargs['upload_to'] = self.upload_to if self.storage is not default_storage: kwargs['storage'] = self.storage return name, path, args, kwargs
Example #19
Source File: files.py From bioforum with MIT License | 5 votes |
def __init__(self, verbose_name=None, name=None, upload_to='', storage=None, **kwargs): self._primary_key_set_explicitly = 'primary_key' in kwargs self.storage = storage or default_storage self.upload_to = upload_to kwargs['max_length'] = kwargs.get('max_length', 100) super().__init__(verbose_name, name, **kwargs)
Example #20
Source File: files.py From GTDWeb with GNU General Public License v2.0 | 5 votes |
def deconstruct(self): name, path, args, kwargs = super(FileField, self).deconstruct() if kwargs.get("max_length", None) == 100: del kwargs["max_length"] kwargs['upload_to'] = self.upload_to if self.storage is not default_storage: kwargs['storage'] = self.storage return name, path, args, kwargs