rndme/download

How to send generated image to server without downloading it in react js?

Closed this issue · 2 comments

here in the wrote the below code for this purpose, but here it download the image and I want to send it to the server?

export const createPDF = async farmId => {
const canvas = await html2canvas(document.getElementById('utmPagePdf'));
const dataURL = canvas.toDataURL('image/png');
downloadjs(dataURL, 'download.png', 'image/png');

const data = new FormData();
data.append('farm_guid', farmId);
data.append('file', '???');

AddUtmReport(data);
};

Please guide me to solve this issue.

Note for you additional you can fetch('data:image/png..................')

then use what you read in the link posted below next to see.

cheers

see: https://github.com/rndme/download/pull/117/files

Closed by:

rndme commented

You can use canvas.toBlob() instead of dataURL, then you can use the Blob as a File. This means you won't really need download.js to append the file to your FormData.