2

Im having some trouble to convert the local file url of a image or document to a blob file. I only have the local file url and the Capacitor url.

They look like this:

File URL:

file:///Users/Milos/Library/Developer/CoreSimulator/Devices/01BDC96A-7A97-407A-A3E9-9E8DA106D176/data/Containers/Data/Application/5A5B54B3-D5DD-4636-B50E-700854472E0F/tmp/cdv_photo_061.jpg

Capacitor URL:

capacitor://localhost/_capacitor_file_/Users/Milos/Library/Developer/CoreSimulator/Devices/01BDC96A-7A97-407A-A3E9-9E8DA106D176/data/Containers/Data/Application/5A5B54B3-D5DD-4636-B50E-700854472E0F/tmp/cdv_photo_061.jpg

I want to upload that file to my server through an api post request. But for that I need the Blob data of the file.

This is my request example:

const formData = new FormData();
formData.append("file", blob);
formData.append("name", fileName);
formData.append("auth", key);
return this.api.post(url, formData, true);

I already tried to convert the file to Base64 but this failed, because the Base64 plugin is deprecated for iOS.

So im really stuck on that problem. Has anyone an idea how I can get my requested solution?

Thanks for every reply!

Milez Zimz
  • 53
  • 4

0 Answers0