chrome 下载函数不传递文件名
chrome download function dose not pass filename
我有一个从 url 下载文件的 js 函数,由于某些原因,在使用 chrome 时,它没有显示正确的文件名。看起来文件名变量没有传递给 chrome.downloads.download 函数(见屏幕截图),另外,mime 类型也不起作用。我在那里添加了警报以进行验证,但它确实显示了正确的文件名。有人知道怎么会这样吗?
谢谢
function downloadDownloader(context) {
const filename = `download-${tabInfo.carNumber}.sh`;
const bash = (downloaderType === 'hls' ? bashTemplate4hls : bashTemplate).compile(context);
const blob = new Blob([bash], {
type: 'text/x-shellscript'
});
const url = URL.createObjectURL(blob);
alert(filename);
chrome.downloads.download({
url,
saveAs: true, filename
});
}
我在这上面花了很多时间,最终我发现是另一个 chrome 扩展导致了这个问题,具体来说,那个扩展叫做“Aria2c Integration”
一旦我禁用它,chrome.downloads.download 功能正常工作。
不知道它是怎么引起的,但就是这样。
我有一个从 url 下载文件的 js 函数,由于某些原因,在使用 chrome 时,它没有显示正确的文件名。看起来文件名变量没有传递给 chrome.downloads.download 函数(见屏幕截图)
谢谢
function downloadDownloader(context) {
const filename = `download-${tabInfo.carNumber}.sh`;
const bash = (downloaderType === 'hls' ? bashTemplate4hls : bashTemplate).compile(context);
const blob = new Blob([bash], {
type: 'text/x-shellscript'
});
const url = URL.createObjectURL(blob);
alert(filename);
chrome.downloads.download({
url,
saveAs: true, filename
});
}
我在这上面花了很多时间,最终我发现是另一个 chrome 扩展导致了这个问题,具体来说,那个扩展叫做“Aria2c Integration” 一旦我禁用它,chrome.downloads.download 功能正常工作。 不知道它是怎么引起的,但就是这样。