Open GeoffFroh opened 4 years ago
One implementation issue is that the current -- and desired -- behavior is that the user clicks the simple link, and the file is downloaded, rather than opened in the browser directly. This is accomplished by setting the content-disposition
value in the http response header from the production media server (see: https://stackoverflow.com/questions/13307499/http-download-file-name).
Because we do not have direct control over the simple URL delivery service at B2, we can't do this. May be possible through the API, however, and there also may be a way of accomplishing this using Cloudflare Workers (see: https://jross.me/free-personal-image-hosting-with-backblaze-b2-and-cloudflare-workers/)
According to the B2 docs, you can cache through Cloudflare edge cdn service. See: https://help.backblaze.com/hc/en-us/articles/217666928-Using-Backblaze-B2-with-the-Cloudflare-CDN
Another method to implement the download behavior would be to use the a
tag's download
attribute which is built into HTML5. However, not all browsers support it fully; notably, Firefox will not download anything outside the origin domain even if the appropriate CORS header is set. We would need to have a fallback in the UI to display a message to the user asking them to right-click and save-as. Here is an example of a javascript solution using Modernizr: https://webdesign.tutsplus.com/tutorials/quick-tip-using-the-html5-download-attribute--cms-23880
@gjost has tested Cloudflare edge cert functionality. Next step is to test in colo environment.
NOTE: Will also probably need to make a page rule in CF so the file is "Save as..." in the browser. see: https://github.com/denshoproject/ddr-public/issues/27
Currently, binary downloads for mezzanines are pointing at the colocation production media server. As the DDR has grown, storage is becoming an issue at the colo. Moving production downloads to b2 will give us more flexibility and also be substantially cheaper in the long run.
In this scenario, we would serve only image/doc mezzanines; access files would remain in the colo production server (also, thumbnailing currently depends on backend access).
Good news: looks like we had already done the groundwork for configuration of the download urls (aka
UI_DOWNLOAD_URL
) in the app settings:https://github.com/denshoproject/ddr-public/blob/master/conf/settings.py#L333
(B2 background -- this case study seems relevant: https://www.backblaze.com/b2/case-studies/sermon-audio.html)