javascript - Set file name and format if file or file location contains neither -


i'd set file name , format of "non-typical file", lack of better words. files stored @ locations such following...

let link = https://.../videoplayback?ipbits=0&initcwndb...d134213ba9465cb74dfd36cde47bf.102638c4a9f3aca357f79ee747dd5f49f1e0f0de

when 1 downloads such files, if different files, end being saved same name , never file extension.

i've tried url.download = link + '.mp4', has no effect whatsoever.

how can this?

according mdn anchor tags download attribute:

can used blob: urls , data: urls, make easy users download content generated programmatically using javascript (e.g. picture created using online drawing web app).

if http header content-disposition: present , gives different filename attribute, http header has priority on attribute.

if attribute present , content-disposition: set inline, firefox gives priority content-disposition, filename case, while chrome gives priority download attribute.

this attribute honored links resources the same-origin.

so if dynamically generating these links , come own server - can set filename. a cross-origin request not work!

you may able use ajax fetch file blob , trick browser thinking data not cross-origin. see this answer 1 possible implementation.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -