'How to upload file on bucket s3 as readable and not downloadable
Im trying to upload sounds on my bucket, with public access. I made a python script for uploading .wav files. Once I executed it : my problem is the following :
- sometimes I got an url which renders a readable sound (I can listen the sound in my browser without downloading)
- sometimes I got an url which triggers a download
I don't understand why there are 2 behaviors, I want to get only readable sound
Here is my python script :
s3 = boto3.resource('s3')
try:
s3.Bucket(BUCKET_NAME).upload_file(KEY, FILENAME, ExtraArgs={'ACL':'public-read'})
except botocore.exceptions.ClientError as e:
if e.response['Error']['Code'] == "404":
print("The object does not exist.")
else:
raise
There is an example of what I want (readable sound) :

And an example of what I don't want anymore (downloadable sound) I don't know why, for many sounds, when I click the url it triggers a download:

Thanks for your time
Solution 1:[1]
This could happen due to one of below two reasons:
- The Content-Type of the file you're uploading is
binary/octet-stream, so while uploading override the Content-Type while uploading the file as below.
2. The browser doesn't support the file type to preview, we can't do it mostly in this case, if the browser is already up to date or else check once by updating the browser.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | DilLip_Chowdary |

