socketio-file-upload icon indicating copy to clipboard operation
socketio-file-upload copied to clipboard

How to upload a file in base64 format?

Open ishan501 opened this issue 3 years ago • 3 comments

Hi, currently there are methods available only for file input. Is there any way to upload base64?

ishan501 avatar Oct 22 '21 16:10 ishan501

You can convert your base64 to an ArrayBuffer, which you can convert to a Blob, and then you can pass an array of Blob to the submitFiles() function. You may want to set some additional properties on the Blob to make it behave more like a File object.

Something like this should work:

const blob = new Blob(yourArrayBuffer, { type: "image/png" }); // set your own MIME type
blob.name = "example.png";
blob.lastModified = new Date().valueOf();
siofu.submitFiles([blob]);

sffc avatar Oct 22 '21 18:10 sffc

Hello, it worked like a charm, thank you so much!!

ishan501 avatar Oct 24 '21 07:10 ishan501

How to upload large files using this method. With chunk size.

anand-010 avatar Dec 23 '21 06:12 anand-010