Hi everyone!
I’m working on a React app that needs to grab images from Google Drive and do some processing on them. I decided to use the react-google-drive-picker package for this.
When I pick files through the picker, I get back a response object that looks like this:
{
"fileId": "2-1QsK9FevTDhvxuGnC1OKp6vZyXGwT8f",
"service": "docs",
"mimeType": "image/jpeg",
"fileName": "my-photo-sample.jpg",
"fileDescription": "",
"category": "photo",
"modifiedTime": 1687045678901,
"thumbnailUrl": "https://drive-thirdparty.googleusercontent.com/16/type/image/jpeg",
"viewUrl": "https://drive.google.com/file/d/2-1QsK9FevTDhvxuGnC1OKp6vZyXGwT8f/view?usp=drive_web",
"previewUrl": "https://drive.google.com/file/d/2-1QsK9FevTDhvxuGnC1OKp6vZyXGwT8f/preview?usp=drive_web",
"fileSizeBytes": 445672,
"orientationAngle": 0,
"rotationValue": 0,
"folderParentId": "2-E7EqXB7FNjXaUefaZPY83Jw88ZdhHM2s"
}
The issue I’m running into is that I can’t actually download or access the image data using the URLs provided. I’ve tried both the viewUrl and previewUrl but they don’t give me the actual image file.
I also attempted to construct a direct download URL like this:
const downloadUrl = `https://drive.google.com/uc?export=download&id=${fileId}`;
But that doesn’t work either.
What I really need is to get the actual image as a blob or File object so I can work with it in my application. Has anyone figured out how to do this with the react-google-drive-picker library?
Thanks in advance for any help!