Opened 2 years ago
Last modified 2 years ago
#34540 closed New feature
[feature request] Run FileField storage callable during runtime and not during buildtime — at Initial Version
| Reported by: | Vasanth | Owned by: | nobody | 
|---|---|---|---|
| Component: | File uploads/storage | Version: | dev | 
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | no | Needs documentation: | no | 
| Needs tests: | no | Patch needs improvement: | no | 
| Easy pickings: | no | UI/UX: | no | 
Description
If the storage callable can be invoked during runtime similar to the "upload_to", it can allow us to choose the storage to use dynamically. This is particularly helpful for SaaS services which prefer maintaining independent storages per client/subdomain.
Something like, the following snippet where local_state.tenant is threading local() which holds the name of the tenant for each request
def tenant_storage():
    tenant = getattr(local_state, "tenant", "default")
    return storages[tenant]
      
  Note:
 See   TracTickets
 for help on using tickets.