我在React组件中有此文件,我将在其中单击download
下载文件:
<a
key={file.attachmentId} className="item uploaded"
href={Pathes.Attachments.getById(file.attachmentId)}
target="_blank"
download
>
Download
</a>
我的文件路径:
static Attachments = class {
static base = baseApi('attachments/download')
static getById = (attachmentsId: any) => baseApi(`attachments/download/${attachmentsId}`)
}
结果,文件在浏览器中打开,但未下载。
答案 0 :(得分:1)
您可以尝试将HTTP标头设置为以下内容:
Content-Disposition: attachment; filename="filename.[yourextention]"
如果这是PDF,这很普遍,浏览器扩展程序要阅读而不是下载!
希望这会有所帮助。