get a broken file
Closed this issue · 7 comments
Deleted user commented
"js-file-download": "^0.4.8",
`
import download from "js-file-download";
download('http://lixing-develop.oss-cn-hangzhou.aliyuncs.com/large_file/1573546365135.png','你')
`
where fix it??
jhoanborges commented
same problem
zhangminggeek commented
same problem in 0.4.12
zhangminggeek commented
it works
import Axios from axios;
function download(url: string, filename: string) {
Axios.get(url, {
responseType: 'blob',
}).then(res => {
fileDownload(res.data, filename);
});
}
ignatvilesov commented
@zhangminggeek is 100% correct. Binary files should be in Blob format 🚀
LoveMeWithoutAll commented
@zhangminggeek responseType 'blob' works perfectly. You saved my life!
donovanclarke commented
This also just saved my life. Thank you kindly.
kindrowboat commented
Thank you @zhangminggeek for the code snippet and @ignatvilesov for the explaination.
I updated the README to hopefully help others from avoiding this gotcha.