DocSpace-buildtools/packages/common/utils/dataUrlToFile.js

10 lines
240 B
JavaScript
Raw Normal View History

2022-09-21 00:39:38 +00:00
export function dataUrlToFile(url, filename, mimeType) {
return fetch(url)
.then(function (res) {
return res.arrayBuffer();
})
.then(function (buf) {
return new File([buf], filename, { type: mimeType });
});
}