Get template file URLs using default_storage#286
Get template file URLs using default_storage#286uci-oit-or wants to merge 1 commit intousnistgov:masterfrom
Conversation
|
Hello, How does that work with S3? Maybe this is not a pb right now, but if you are using the contracts plugin (with procurement files) or the billing plugin (with invoice files) then are the files uploaded to S3 protected in any way or could anyone access them freely? |
|
Hi @rptmat57, Thanks for the response! I don't think that this PR would change the behavior with protected files. It only changes how the URL gets inserted into the template file. So if a page is staff only, staff would be the only ones able to access the file. In our case, because the S3 bucket is private, the URL needs to be built dynamically each time with auth info (the URL will expire after We're not utilizing file uploads with the contracts or billing plugins, just NEMO itself, so I can't really speak on this. The way we're connecting to S3 is by installing django-storages via pip. Then inside of STORAGES = {
"default": {
"BACKEND": "storages.backends.s3.S3Storage",
"OPTIONS": {
"location": "media",
"session_profile": "<SESSION_PROFILE>",
"bucket_name": "<BUCKET_NAME>",
"region_name": "us-west-2",
"signature_version": "s3v4",
},
},
"staticfiles": {
"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage",
},
}Hope this makes sense. Thanks, |
|
Hi @rptmat57, Are there any updates with this? Thanks, |
|
Hi @rptmat57, I was wondering if there was any chance of this being merged? If not, I can close this PR and just apply the changes in my fork. Thanks, |
|
Hi @abuckles-uci and thank you for your patience and the contribution. This is unlikely to be merged anytime soon. |
|
Thanks for letting me know! I'll close this PR and implement the change in my fork only. |
Hello @rptmat57,
This is a suggestion to possibly make NEMO's method of retrieving file URLs work with more storage methods. This came about because at UCI we are attempting to have files uploaded to Amazon S3 (with the help of django-storages). Viewing/downloading the files worked well when using
FileFieldorImageField, but errors occurred with the customization template files (emails, jumbotron, etc.) since they use a prefixedMEDIA_URL.The change I made adds a custom template tag that utilizes
default_storage.url. I tested that this also works with the previous way we were storing media files (locally on disk in amediafolder). This should hopefully mean the change won't negatively affect any other NEMO users.Please let me know if this change isn't wanted/needed or if more needs to be added.
Thank you,
Aaron