etianen / django-s3-storage

Django Amazon S3 file storage.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Update settings to define multiple S3 buckets

VaZark opened this issue · comments

Use Case : When dealing with multitenant services, it'd be ideal if we could define the multiple S3 buckets for each client and dynamically set the bucket to use with django-storages.

Moreover, we do not have to look far for inspiration. We can reuse the Muti-Database dict format to handle and set the S3 bucket config. Users can then dynamically select the bucket with threading local or their preferred setup.

## settings.py
BUCKETS = {
    "S3_1": {
        "BUCKET_NAME": "",
        "ENDPOINT_URL": "",
        "MAX_AGE_SECONDS": "",
        "PUBLIC_URL": "",
        "FILE_OVERWRITE": "",
    }, 
     "S3_2": {
        "BUCKET_NAME": "",
        "ENDPOINT_URL": "",
        "MAX_AGE_SECONDS": "",
        "PUBLIC_URL": "",
        "FILE_OVERWRITE": "",
    }
}

It's an interesting idea, but needs a bit more fleshing out.

  • What advantage is there splitting different client objects over different buckets? AFAIK, S3 permissions are per-object in general.
  • How would an individual file be routed to a particular bucket?