Reputation: 78
I am using DigitalOcean Spaces/Buckets to store audio files and have a URL being generated which points to that file. In my html file, I am accessing that audio as:
<audio controls>
<source src="my_digital_ocean_file_url">
</audio>
This file is not getting played on the front-end and when I enter the URL on chrome, the file gets downloaded instead of playing on the browser. Is there a way to make the files on the URL playable?
Upvotes: 0
Views: 1067
Reputation: 78
I was using and outdated browser. Updating the browser solved the issues for me.
Upvotes: 0
Reputation: 1833
This is related to the backend. You need to provide 'contentType' as audio. The implementation is different based on the programming language you are using for the backend. Please check the sample code in PHP.
$s3->create_object($bucket, $file_name, array(
'fileUpload' => $resized_image,
'contentType' => $_FILES['image']['type'],
'acl' => AmazonS3::ACL_PUBLIC
));
The above issue is not limited to audio files, it's for PDF, Images as well. Follow are some helpful reference
How to view pdf's stored in spaces without them being downloaded
amazon s3 - image downloading instead of displaying in the browser
Upvotes: 1