Hi,
I’m building a plugin to save a message’s attachment and send it directly to a Google Drive.
The problem I’m facing is that the context.downloadAttachment() function is returning a broken file:
// attachments state contains message_id and attachment_id of all the conversation's attachments
const handleAttachmentDownload = (index) => {
context.downloadAttachment(
attachmentstindex].messageData.id,
attachmentstindex].attachmentData.id
)
.then((resp) => {
console.log(resp)
setPreview(URL.createObjectURL(resp))
});
};
The promise is successfully returning a File
but as we try to handle the file (previewing or sending it to a google drive it for example) the resulting uploaded file is broken.
Am I doing something wrong here? I’ve tested the exact same flow with a simple file input uploader and it works fine.
Thanks