云开发接单
云开发接单
  • 发布:2023-07-07 13:41
  • 更新:2024-04-14 12:29
  • 阅读:462

Refused to get unsafe header "content-disposition" uni.downloadFile下载云存储文件出现报错怎么解决

分类:uniCloud

Refused to get unsafe header "content-disposition" uni.downloadFile下载云存储文件出现报错怎么解决

运行在本地游览器进行下载的

2023-07-07 13:41 负责人:无 分享
已邀请:
DCloud_uniCloud_WYQ

DCloud_uniCloud_WYQ

这是个警告,这个警告本身不影响下载。可以看看有没有其他报错

c***@163.com

c***@163.com

uniapp下载第三方存储图片报错Refused to get unsafe header "content-dispositio"怎么解决的老哥

阿全uniapp

阿全uniapp

我也遇到了。查看错误

const downloadFile = / @PURE / defineTaskApi(
API_DOWNLOAD_FILE,
({ url, header = {}, timeout = __uniConfig.networkTimeout.downloadFile }, { resolve, reject }) => {
var timer;
var xhr = new XMLHttpRequest();
var downloadTask = new DownloadTask(xhr);
xhr.open("GET", url, true);
Object.keys(header).forEach((key) => {
xhr.setRequestHeader(key, header[key]);
});
xhr.responseType = "blob";
xhr.onload = function() {
clearTimeout(timer);
const statusCode = xhr.status;
const blob = this.response;
let filename;
const contentDisposition = xhr.getResponseHeader("content-disposition");

在这里xhr.getResponseHeader("content-disposition");强制获取了这个header中的content-disposition

兄弟你解决没有。

要回复问题请先登录注册