如何下载更改文件名的文件?

How to download file with changed filename?

让我们考虑这样的情况:

现在我使用简单的 <a>...</a> 和 angular 属性:

<a ng-href="{{ vm.resource.attachment_url }}"> Download attachment </a>

其中vm.resource.attachment_url显然是用内部API

获取的对象

我无法在 Cloudinary 中找到这样的实现 API。另外,我希望我足够清楚。

使用锚点的download attribute,指定接收下载文件的名称:

<a ng-href="{{ vm.resource.attachment_url }}" download="my-custom-attachment.png"> Download attachment </a>

查看the demo属性的工作原理。

另一种选择是将文件内容下载到 Blob 对象中,然后使用修改后的文件名抛出 blob 内容。检查 demo.

Cloudinary 支持将图像作为附件传送,强制它以原始文件名下载和存储。
这是通过简单地将 fl_attachment 添加到 URL 或在使用辅助方法时将 flags 参数设置为 attachment 来完成的,例如:
cloudinary.url('kouyyvrmbubwkrh7ayvk.png', {flags: 'attachment'}); 在您的特定情况下,这将导致图像保存为 guitar.png.

更多信息:http://support.cloudinary.com/hc/en-us/articles/202521252-How-can-I-deliver-an-image-as-an-attachment-