使用远程文件的下载属性 [英] Using download attribute with remote file
问题描述
我试图让下载
属性在远程链接上映像。
这里是我试图完成的一个例子: $ b
< a id ='image' href ='remoteFileName.jpg'download ='newFileName.jpg'/>
所以当点击链接而不是浏览器下载remoteFileName.jpg时,它会将其保存为newFileName .jpg
我以某种方式理解交叉来源策略,它是这不起作用的原因。我正在寻找一个解决这个问题的办法,有什么想法吗?
解决方案如果您无法自行托管文件,可以通过传递代理服务器来解决此问题。通过端点一个文件名,服务器可以管理下载过程并避免跨域挂断。
I'm trying to get the download
attribute to work on a remote link to image.
Here is an example of what I am trying to accomplish:
<a id='image' href='remoteFileName.jpg' download='newFileName.jpg' />
So when the link is clicked instead of the browser downloading remoteFileName.jpg, it will save it as newFileName.jpg
I understand the cross origin policy somehow, that it is the reason why this doesn't work. I'm looking for a workaround for this, any ideas?
If you're unable to host the file yourself, you might be able to get around this by having a pass through proxy that you host. Pass the endpoint a filename and the server could manage the download process and avoid the cross domain hangups.
这篇关于使用远程文件的下载属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!