MS Edge 正在将下载重命名为 "true.txt"、"true.jpg" 等
MS Edge is renaming downloads to "true.txt", "true.jpg", etc
我有以下 link:
<a download="true" href="/admin/employees/12/attachment">test.txt</a>
在我那条路线的控制器中,我有这个:
def attachment
response.headers['X-Download-Options'] = 'open'
attachment = @employee.latest_attachment
data = attachment.attachment_data.file_data
send_data(data, disposition: 'attachment', filename: attachment.name, type: attachment.content_type)
end
现代浏览器都能正确下载文件名正确的文件,但 Edge 将名称更改为“true”+ 正确的扩展名。
如何设置 Edge 的文件名?
link 上的 download
标记决定了 Edge 的文件名,因此您应该将其设置为:
而不是 true
<a download="my_filename" href="/admin/employees/12/attachment">my_filename.txt</a>
我有以下 link:
<a download="true" href="/admin/employees/12/attachment">test.txt</a>
在我那条路线的控制器中,我有这个:
def attachment
response.headers['X-Download-Options'] = 'open'
attachment = @employee.latest_attachment
data = attachment.attachment_data.file_data
send_data(data, disposition: 'attachment', filename: attachment.name, type: attachment.content_type)
end
现代浏览器都能正确下载文件名正确的文件,但 Edge 将名称更改为“true”+ 正确的扩展名。
如何设置 Edge 的文件名?
link 上的 download
标记决定了 Edge 的文件名,因此您应该将其设置为:
true
<a download="my_filename" href="/admin/employees/12/attachment">my_filename.txt</a>