django-storage

Add Dynamic Content Disposition for file names(amazon S3) in python

江枫思渺然 提交于 2021-02-07 20:30:17
问题 I have a Django model that saves filename as "uuid4().pdf". Where uuid4 generates a random uuid for each instance created. This file name is also stored on the amazon s3 server with the same name. I am trying to add a custom disposition for filename that i upload to amazon s3, this is because i want to see a custom name whenever i download the file not the uuid one. At the same time, i want the files to stored on s3 with the uuid filename. So, I am using django-storages with python 2.7. I

Add Dynamic Content Disposition for file names(amazon S3) in python

走远了吗. 提交于 2021-02-07 20:26:13
问题 I have a Django model that saves filename as "uuid4().pdf". Where uuid4 generates a random uuid for each instance created. This file name is also stored on the amazon s3 server with the same name. I am trying to add a custom disposition for filename that i upload to amazon s3, this is because i want to see a custom name whenever i download the file not the uuid one. At the same time, i want the files to stored on s3 with the uuid filename. So, I am using django-storages with python 2.7. I

Django app does not load images from AWS bucket's media folder

心不动则不痛 提交于 2021-02-07 04:21:15
问题 I'm using django-oscar ,and wanted to serve my static files with AWS S3. To config my s3 bucket I've created a module called aws with conf.py and utils.py files. On my website when I upload an image to the product it gets uploaded well with the correct path to my aws s3 bucket, but then after very short time the path changes from https://mybucketname.s3.amazonaws.com/media/cache/..../image.jpg to https://mybucketname.s3.amazonaws.com/cache/..../image.jpg The images are in the media folder in

Django “chunked uploads” to Amazon s3

妖精的绣舞 提交于 2021-01-29 16:48:38
问题 We're using the S3Boto3Storage to upload media files to our s3 storage on Amazon. This works pretty well. Since we're using Cloudflare as a "free" version we're limited to a maximum of 100MB per request. This is a big problem. Even the Enterprise plan is limited to 500MB. Is there a way to use a kind of "chunked uploads" to bypass the 100MB-per-request limit? model.py class Media(models.Model): name = models.CharField(max_length=100, null=True) file = models.FileField(upload_to=get_path)

Error in path with django-storages with dropbox

蹲街弑〆低调 提交于 2021-01-29 11:41:47
问题 This is my settings code DEFAULT_FILE_STORAGE = 'storages.backends.dropbox.DropBoxStorage' DROPBOX_OAUTH2_TOKEN = "my token" DROPBOX_ROOT_PATH = "Apps/Djangoproject" The error i am getting while uploading a image: ValidationError: did not match pattern '(/(.|[\r\n])|id:.)|(rev:[0-9a-f]{9,})|(ns:[0-9]+(/.*)?)' how to solve this issue? Anyone know how to solve this issue? 回答1: You're supplying a path of "Apps/Djangoproject" , and the error is indicating that it does not match the expected path

Storing Django FileField with leading slash

泄露秘密 提交于 2021-01-29 05:33:45
问题 I have a database used by two different systems and as a result I actually need the FileField value to have a leading slash, like so: /dirs/filename.ext In Django, however, FileField values can't have a leading slash since it breaks how they interact with MEDIA_ROOT . So my suspicion is that I either have to create a custom storage class or somehow customize FileField so that the leading slash is stripped out when read and restored when saved. In case anyone is wondering why I am doing this:

Setting up media file access on AWS S3

五迷三道 提交于 2020-04-30 11:25:06
问题 Im using boto3 and django-storage libraries for apload media files of my django project. storage_backends.py class PrivateMediaStorage(S3Boto3Storage): location = settings.AWS_STORAGE_LOCATION default_acl = 'private' file_overwrite = False custom_domain = False class PublicStaticStorage(S3Boto3Storage): location = settings.AWS_PUBLIC_STATIC_LOCATION settings.py AWS_STORAGE_LOCATION = 'media/private' AWS_LOCATION = 'static' AWS_PUBLIC_STATIC_LOCATION = 'static/' DEFAULT_FILE_STORAGE = 'path.to

Setting up media file access on AWS S3

巧了我就是萌 提交于 2020-04-30 11:24:27
问题 Im using boto3 and django-storage libraries for apload media files of my django project. storage_backends.py class PrivateMediaStorage(S3Boto3Storage): location = settings.AWS_STORAGE_LOCATION default_acl = 'private' file_overwrite = False custom_domain = False class PublicStaticStorage(S3Boto3Storage): location = settings.AWS_PUBLIC_STATIC_LOCATION settings.py AWS_STORAGE_LOCATION = 'media/private' AWS_LOCATION = 'static' AWS_PUBLIC_STATIC_LOCATION = 'static/' DEFAULT_FILE_STORAGE = 'path.to

Django amazon s3 SuspiciousOperation

徘徊边缘 提交于 2020-01-14 09:52:09
问题 So when i try accessing a certain image on S3 from my browser everything works fine. But when python is doing it i get a SuspiciousOperation error. My static folder is public on S3 so i really have no idea where this is coming from. Publication.objects.get(id=4039).cover.url Traceback (most recent call last): File "<console>", line 1, in <module> File "/home/vagrant/.pyenv/versions/blook/lib/python2.7/site-packages/django/db/models/fields/files.py", line 64, in _get_url return self.storage

Django amazon s3 SuspiciousOperation

[亡魂溺海] 提交于 2020-01-14 09:52:05
问题 So when i try accessing a certain image on S3 from my browser everything works fine. But when python is doing it i get a SuspiciousOperation error. My static folder is public on S3 so i really have no idea where this is coming from. Publication.objects.get(id=4039).cover.url Traceback (most recent call last): File "<console>", line 1, in <module> File "/home/vagrant/.pyenv/versions/blook/lib/python2.7/site-packages/django/db/models/fields/files.py", line 64, in _get_url return self.storage