Open LagunaElectric opened 10 months ago
Could you please try the following snippet instead ? @LagunaElectric
async downloadImage() {
await download(FilePicker1.files[0].data, 'sample.png', 'image/png')
}
@arunvjn That gives the same result, downloaded file is corrupt and can't be opened.
import external js library ky
, thanks for sindresorhus
export default {
DownloadBinary: async () => {
let result = await ky.post("http://x.x.x.x/download",{});
let buffer = await result.arrayBuffer();
const blob = new Blob([buffer], {type: 'application/octet-stream'});
const data = URL.createObjectURL(blob);
await download(data, "sample.pdf","application/octet-stream")
}
}
@LagunaElectric
Is there an existing issue for this?
Description
A users API returns an image as a binary octet stream. When you try downloading the stream with the following code snippet you get a corrupted file.
Here I've asked the user for a sample output from their API and uploaded that as a file to the Filepicker widget. You can find the sample in the attached Zendesk thread.
Steps To Reproduce
Environment
Production
ZD Thread
Ticket 1295
Version
Cloud 1.9.59-SNAPSHOT