1

I have base64 of an image.. I want to send it to the api using formdata. How can that be achieved? I am using react native signature canvas to get the base64 of the signature.

let signature = base64signature;
const formdata = new FormData();
formdata.append('attachments', {
  uri: signature,
  name: 'logo',
  filename: 'logo',
  type: 'image/png',
});

How to convert Base64 String to javascript file object like as from file input form?
I followed this link as well but dont understand how to send it to the api as formdata.. It's constantly giving network error.

I have also tried to convert it to blob and send but that didn't work as well. Can anyone help me with this?

Phil
  • 141,914
  • 21
  • 225
  • 223
Yus
  • 53
  • 6
  • Could you add the code that you tried? – MaartenDev Jan 23 '22 at 18:12
  • I have added the code above. – Yus Jan 23 '22 at 18:19
  • No, the code that transforms the base64-encoded string to a `File` object. Please also include the error message(s) in your question – Phil Jan 24 '22 at 05:55
  • The object you're appending to your `formData` isn't any of the [acceptable parameter types](https://developer.mozilla.org/en-US/docs/Web/API/FormData/append#parameters). It must be be _"a `USVString` or `Blob` (including subclasses such as `File`)"_ – Phil Jan 24 '22 at 05:59

0 Answers0