Search code examples
ruby-on-railsamazon-web-servicesamazon-s3videorails-activestorage

Videos Uploaded with rails ActiveStorage to AWS S3 are downloaded instead of playing when calling (clicking) on the link generated


this is kinda tricky.. let's make this clearer :

I'm using a ruby on rails app as back-end for my mobile application, when i upload a video from my ruby app Dashboard and store it on AWS S3 Storage it works perfectly, and when i retrieve the URL for the video it works as well , the thing when i click it it automatically download the video instead of playing it, i checked the meta data of the object inside my AWS Console it has the ( System defined Content-Type video/mp4 ) but as the attached screenshot show it doesn't recognize it as a video (as type is - as of null )

my response is always as JSON since i use the ruby app for the web services and the dashboard only ( i get the correct response )

PS: the video uploaded manually from the AWS Console plays when u open the link.

this is the difference between the video uploaded using my ruby app and the video uploaded manually which is highlighted in red


Solution

  • Look into how to set S3 Content Disposition with the library you're using. You'll need to probably do this when you're uploading the file, or you might be able to coerce it at request time when generating the link to the asset.