Uploading Multiple Images to One Drive through Graph API

I'm able to upload a single photo to one drive with the below code. I need to loop through multiple photos and upload them. Photo url is stored in variable {{getPhotos.data.FullUrl}}, name of photo is in {{getPhotos.data.FileName}}

const imgData = await getBinaryImageUrl.trigger({additionalScope: {imageUrl: "https://image.jpg" }});

downloadPhotosOneDrive.trigger();

Though not using OneDrive, I think the application would be the same:
https://docs.retool.com/docs/upload-multiple-files-through-a-gcs-s3-resource

2 Likes

Ok this is defnitley helpful, but since i'm using two APIs one to get the binary image url and one to upload how I modify

async function go() {
for (let i = 0; i < fileInput1.value.length; i++) {
await uploadToS3.trigger({
additionalScope: {
i: i,
},
});
}
}

return go();

So i got everything to work except getting the imageName to the second api

var myStringArray= getPhotos.data.FullUrl;
var arrayLength = myStringArray.length;

for (var i=0; i <arrayLength; i++) {
await getBinaryImageUrlOneDrive.trigger({
additionalScope: {
imageURL: getPhotos.data.FullUrl[i],
imageName: getPhotos.data.FileName[i]
},
})
}

I think it should be
getPhotos.data.FileName[i].name

I'm sure there can be improvement to the code but this works

var myStringArray= getPhotos.data.FullUrl;
var arrayLength = myStringArray.length;

//async function go() {
for (var i=0; i <arrayLength; i++) {
await getBinaryImageUrlOneDrive.trigger({
additionalScope :{
imageURL: getPhotos.data.FullUrl[i]
}
}),
await downloadPhotosOneDrive.trigger({
additionalScope: {
imageName: getPhotos.data.PhotoId[i]+'.jpg',
imageCustomer: tableCustomer.selectedRow.data.Customer
}
});
}

2 Likes