I try to upload a photo that I have in a URL on another server, but it does not work for me or I do not know how to upload them in this case I am going to upload a photo but I also want to upload files that will upload to that URL.
const img = await fetch("http://example.com/api/photo")
await gapi.client.drive.files.create({
resource: {
name: "New Folder",
body: img,
}
})
I believe your goal as follows.
const img = await fetch("http://example.com/api/photo").Modification points:
fetch, and the blob is uploaded to Google Drive.fetchwithmultipart/form-data.When above poiints are reflected to your script, it becomes as follows.
Modified script:
multipart/form-data.Note:
http://example.com/api/photois the direct link of the image data.uploadType=multipart. In this case, the maximum file size is 5 MB. Please be careful this. When you want to upload the file with the large size, please check the resumable upload. RefReferences: