简体   繁体   English

用户上传的内容在我的AWS S3存储中会放在哪里?

[英]Where does user-uploaded content go in my AWS S3 storage?

I've set up my AWS S3 storage for my Django project. 我已经为Django项目设置了AWS S3存储。 My static folder in my S3 Bucket has all my static files. 我的S3存储桶中的static文件夹包含我所有的静态文件。 However where do the files which would usually go in media go? 但是,通常会放在media的文件在哪里呢? ie files uploaded from users? 即从用户上传的文件?

I use a /Media root in my AWS bucket and I set the file upload directories to go there 我在AWS存储桶中使用/ Media根目录,并将文件上传目录设置为该目录

in settings.py 在settings.py中

DEFAULT_FILE_STORAGE = 'yourapp.storage_backends.MediaStorage'

In another file lets say storage_backend.py, I defined the following 在另一个文件中,比如storage_backend.py,我定义了以下内容

from storages.backends.s3boto3 import S3Boto3Storage

class MediaStorage(S3Boto3Storage):
    location = 'media'
    file_overwrite = False

and Finally this is the data type in my models.py 最后这是我的models.py中的数据类型

to_upload = models.FileField()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM