flask-s3 icon indicating copy to clipboard operation
flask-s3 copied to clipboard

Custom root folder under S3 bucket

Open jace opened this issue 10 years ago • 1 comments

I have a situation where having the static tree replicated directly under the S3 bucket root folder is problematic. I have a few apps that share most of their static assets via a single Blueprint (named Baseframe). To use Flask-S3 with them, I'd need to do something like this:

App1:
+- app1-static (bucket)
   +- baseframe/
   +- static/

App2:
+- app2-static (bucket)
   +- baseframe/
   +- static/

... and so on, which is less than ideal since Baseframe's (non-trivial collection of) assets are (a) being duplicated and (b) being delivered from different URLs at each site. It'll be nice if I could instead use a single bucket for all apps and have the assets stored like this (using app.name for the app static path):

App1, App2, ...:
+- all-app-static (bucket)
   +- baseframe/
   +- app1/
   +- app2/

While I could achieve this right now by having the app static path named "app1", "app2" etc, and have Flask-S3 simply replicate this, using anything other than "static" will interfere with the app's URLs when not using Flask-S3. It'll be nice if Flask-S3 can instead accept a configuration parameter for the app static path and write to that folder name.

jace avatar Mar 31 '14 18:03 jace

I think I understand what you are trying to accomplish. One solution would be to make app1 and app2 into Blueprints and setting their static folders manually. Otherwise, you can change the app's static_folder attribute and both Flask locally and Flask-S3 should follow suit. (I haven't actually tested this, so if this is not the case, then we should update it.)

Let me know if you've tried these (particularly the last option) and if that doesn't work, I think we can figure out a solution using Flask's own machinery, rather than adding another config setting to Flask-S3.

eriktaubeneck avatar Apr 03 '14 19:04 eriktaubeneck