I’m developing a mobile application with Ionic Angular that uses the Capacitor Plugin to read multiple images from the gallery and upload to AWS Storage. Firstly I’m thinking that I’m supposed to use Camera.pickImages to pick the images and loop through the array and convert each to blob and upload to the server. The difficulty lies in converting to blob. After reading through documentation, I could not figured out how to solve this. Please kindly help to convert to blob or provide a better approach in solving this problem.
const images = async pickItemImages (){
const images = await Camera.pickImages({
quality: 100,
presentationStyle: 'fullscreen',
limit: 5,
});
images = images.photos;
for(let i = 0; i<images.length; i++){
const blobData = //convert to blob
//upload to server
}
}
Here is my backend written in Laravel:
$file = $request->file('file');
$extension = $file->getClientOriginalExtension();
$filename = md5(mt_rand() . time()) . '.' . $extension;
$filePath = 'uploads';
$storagePath = Storage::disk('items')->putFileAs($filePath, $file, $filename ,'public');
$path = Storage::disk('items')->url($storagePath);