File download dialog for photos hosted on Amazon S3 - django

My web application will host full size photos on Amazon S3 and we use S3 as our media server. We also allow the users to download the full-size photos. Our web server is on a different hosting company. On our web application, how can we force a File Download dialog box instead of showing the photo in browser directly from an Amazon S3 URL? For example, the image url could be "http://my.s3.amazonaws.com/12345.jpg"
One solution would be to download the image to our web server which is running Django, and then force a file download dialog, but will cost double bandwidth and double the download time as well.
Thanks!

See if you can get S3 to specify the content type of the files as application/octet-stream.
I have just verified this. In the AWS management console you can select a file, click on Properties, select the Metadata tab and then set the Content-Type to "binary/octet-stream". If it's e.g. image/jpeg it will display in the browser. If it's changed to binary/octet-stream it forces the browser to download it instead.

Related

how to continue uploading data including images to rest api like facebook posting

I am working in building a real estate application
using spring boot java and the application in the aws server and images uploading in s3 bucket
what i want is that when the user add a propery if the the user close the app
the uploading task continue in the background and notify when complete
I found a resumeUpload method looks like just you want here.
Also an upload example in the aws s3 document.
Wish this help.

Google Tag Manager doesn't work with AWS S3 hosted website

So I have a website hosted on AWS S3 with added SSL protocol https://calc2burn.pl. I have added a Google Tag Manager scripts to the index.html file, but when I'm clicking preview on GTM site I receive message that it can't connect to website.
After clicking preview the Tag Manager opens up site in a new tab but nothing more happens. I've added my code correctly. I've been searching for solution for last 15 hours. I thought that maybe it's a problem with CloudFare and have modified script as instructed but that didn't help.
The weirdest thing is that once for 100 attempts to reconnect I've received a massage that it has connected to website but the actual Tag Manager account site showed that it's not connected.
Ok, so obviously the old version of index.html was still in CDN cache. I had to invalidate all files in the CloudFront distribution. I have found all helpful information on this site.

Serving private media files from S3 to single page React App (Django DRF backend)

I have set up an S3 bucket on AWS where I upload my sensitive ‘media’ files from my Django DRF + React app. The files are not public. I use boto3 and Django-storages for that and the upload process works fine. I can also download the files for report generation from backend to return PDF response.
I would now like to display those files one by one from frontend. It seems like I now have two options:
Create a route in Django API/urls to handle media requests and point the app to the media directory. This way, the AWS login is handled by the backend server. This seems to beat the point of using a CDN as all media requests would go via the backend server?
Incorporate login credentials to React front end. This seems insecure.
What would be the recommended way to achieve this? I can’t seem to find the required information.
Thank you.

How to update a static html website hosted on Amazon S3

I have hosted a static HTML website hosted on aws s3 using the Udemy video tutorial Amazon Web Services (AWS) Certified 2018 - 4 Certifications.
I have successfully hosted the website, however when I attempted to update the site by changing the some text in the index.html file and then uploading the new index.html to S3, I do not see my updates. Rather, I see the original webpage content. Occasionally, I am able to refresh the page or close my Chrome browser in order to see my changes, however it is not stable. Please help!
It sounds like your browser is caching the content.
If you open a different browser (eg Firefox) and the content has updated, then everything is fine on S3. It's just a matter of clearing your browser cache or waiting for the cached content to expire.

Update Django server after creating thumbnail with AWS Lambda

I have a Django web project that is using Amazon S3 for media files. The file upload is happening async direct from the browser.
I need to create some thumbnail images for each file that is uploaded. I found a tutorial for how to do this using AWS Lambda (which I've never used before) but seems like the future of web.
The only issue I am trying to figure out in my head is: how I will update my database back on the django web server with the information for the newly created thumbnail images? I intend to create a new database model (thumbnails) that will store the URL and tie the thumbmail to the main image information.
The only thing I have come up with is to expose a url on my web app to accept HTTP requests (assuming lambda can send HTTP requests). So when the lambda function completes a thumbnail image, it will send the request to my web app with the information for the newly created thumbnail image using POST or PUT.
The thing I don't like about this approach is that it won't work when developing locally. Does anyone have any experience using Lambda to create thumbnails and then communicating back with your web server which differs from my proposed plan?