Force asset download instead of playing in browser - javascript

I'm currently using Azure Media Services and I'm unable to force a video download instead of in-browser player when clicking the "download" link generated after creating a download locator.
I've got the video.js player working fine with a streaming locator but whatever I do, it seems that I can't force a browser to download the video (well, right click and save work fine but the end user probably won't expect this to download the video directly).
Is there a working example somewhere that shows how to force a client browser download ?
I tried adding download tag to the html element but that did not help.
</i>
FYI the content-type header of the response is
video/mp4
When you click on the element it sends the request to the backend service which generates a SAS and redirects the request for blob download.
Thank you

Related

Downloading an mp4 file using javascript

How do I allow users to download mp4 files from a different server that isn't owened by me? No approach I've come across has worked so far. Here's what I've tried:
The download attribute for a tags: Download - not working for me (as in - the attribute doesn't have an effect. Tested in Google Chrome)
Place a hidden <iframe> on the page - doesn't work either since I can't change the MIME-type, the video simply gets played back
Download using ajax - not a good solution as well, since this loads the entire file into the user's RAM. Some videofiles are 1GB+.
Is there any other method? Thanks!

Streaming WAV files in browser from pre-signed AWS S3 URL

I have pre signed URL from Amazon S3 something like below
https://bucketname.s3.amazonaws.com/audios/myfile.wav?AWSAccessKeyId=XXXXXXXXXXXXX&Expires=1556734678&Signature=A1BL1tnidbSM6AGXYwvlA99vXEk%3D
This URL works fine and gives me the audio file. However, browser doesn't really play the file automatically and instead I have to right click, save as WAV file and they play it on my local player.
I want it to be played/streamed then and there on the browser. The browser shows default Chrome audio player, but it stays disabled.
Is there a setting in AWS for this or can I use some audio player libraries to play it or there is different way to get the URL? I have been searching this on the forums but couldn't get a solution that will work for me.
Thanks

How to trigger file download on URL without extension

I am trying to trigger a download when the user clicks on a link.
The files hosted on servers I do not own/have no control over so I can't just add direct URLs to files (for example: https://example.com/video.mp4). I have tried the following code but it does not do what I want it to do.
<a href="https://example.com/filedownload?file=video" download>Download</a>
I expect the code to download the file when the user clicks the link. But when the user clicks the link, it opens a new tab at the URL instead of downloading the file.
Also, the link is not a MediaFire style download. If you press CTRL+S when on the page you get linked to it downloads video.mp4.
There are three ways to trigger saving a URL to disk instead of following the default behaviour for the browser.
The download attribute only works for same origin URLs.
A Content-Disposition header which requires you control the server hosting the file.
Lying about the content type, ditto, and which is a terrible approach anyway.
The only way to achieve what you want would be to serve the file from a server you do control.

Open Saveas dialog in angularjs 1.2 (or javascript) and HTML 4x

I am AJAX call and when the server (REST service) sends the response it is actually a link to the generated file something like
/project/tmporaryFiles/file.abc
(File extension is also customized) It is just a text file. when I use $window.open then it just opens the text file in the browser and displays the text. I would like to open a saveas dialog box so that user user should be able to save the file instead of viewing it in the browser. I have tried multiple threads of stackoverflow but could not found solution. Most of the solutions are for HTML5 i.e. the download attribute in anchor, I believe this is not available in HTML4x.
One solution I am trying to find is to create a Blob with the response link but that I am unable to do.
Also note the file can be more than 100MB as well based on the data processing and input by the user.
I you want to force the download without using HTML5 download attribute, you will need to set Content-Disposition on response header.
This can be done on server side and not client.

download video link for iPad/iPhone

how to create a download video link for iPad/iPhone, I am using something like this
<a id="wellcome-video-strem" href="iphone.m4v"><img src="imgButtonDownloadVideo.png" alt="Download Video" /></a>
but clicking on this link start to play video file in iPad.
Mobile Safari provides no means to save a file to the device's video library.
You might be able to store data using local storage, but I doubt you will be allowed to store enough data to make saving video feasible (and it would limit access to the saved data to your web site). If you took this approach then you would probably have to resort to generated a data: scheme URI in a <video> element to play it back.
iPads and iphones support HTML5, so i think you should go for this approach.
Here is a link http://www.w3schools.com/html5/tag_video.asp for HTML5 video tag.
my bad. i misunderstood your post.
There is no way to download a video to your iphone/iPad. You can link your customers to a free download manager on the Appstore to download files.

Categories

Resources