I want to download file from external server but after renaming it. Let's say http://playtictactoe.atwebpages.com/logo.png is an image file I want to download. I have used the following HTML:
我想从外部服务器下载文件,但重命名后。假设http://playtictactoe.atwebpages.com/logo.png是我要下载的图像文件。我使用了以下HTML:
<a href="http://playtictactoe.atwebpages.com/logo.png" download="myName.png">
Download File
</a>
But this doesn't rename the file. I've read somewhere that this is because of Response Header on server. Is there any way to ignore Response Header on client side? Else guide me any other solution.
但是这不会重命名文件。我在某处看到这是因为服务器上的响应标头。有没有办法忽略客户端的响应标头?否则指导我任何其他解决方案。
1 个解决方案
#1
1
You can download the file as a buffer and resave with the file api like descriped here:
您可以将文件下载为缓冲区并使用文件api重新保存,如下所述:
HTML5 File API downloading file from server and saving it in sandbox
HTML5 File API从服务器下载文件并将其保存在沙箱中
Or lookup FileAPI and XMLRequest to Buffer. You download the file as binaryBuffer save it with fileAPI and rename it. This should also work in Firefox. But this is not the simple solution you are searching for. Even though it works ;-)
或者将FileAPI和XMLRequest查找到Buffer。您将文件下载为binaryBuffer,使用fileAPI保存并重命名。这应该也适用于Firefox。但这不是您正在寻找的简单解决方案。即使它有效;-)
You can then rename the file like you want.
然后,您可以根据需要重命名该文件。
Cheers
#1
1
You can download the file as a buffer and resave with the file api like descriped here:
您可以将文件下载为缓冲区并使用文件api重新保存,如下所述:
HTML5 File API downloading file from server and saving it in sandbox
HTML5 File API从服务器下载文件并将其保存在沙箱中
Or lookup FileAPI and XMLRequest to Buffer. You download the file as binaryBuffer save it with fileAPI and rename it. This should also work in Firefox. But this is not the simple solution you are searching for. Even though it works ;-)
或者将FileAPI和XMLRequest查找到Buffer。您将文件下载为binaryBuffer,使用fileAPI保存并重命名。这应该也适用于Firefox。但这不是您正在寻找的简单解决方案。即使它有效;-)
You can then rename the file like you want.
然后,您可以根据需要重命名该文件。
Cheers