I hope you are having a great day. I am working on building an automation service that takes a file from Google Drive (based on file ID/URL) and import it to Google Photos. Please have a look at this demonstration video. This service will be deployed as API on my hosting and integrated to a software where I have access to OAuth Tokens for Google APIs (at the moment, one user account is authenticated, but we are hoping to scale the solution later so users can authenticate themselves based on google account, allow OAuth delegation and use the service - this part is clear).
Using Google Apps Script, I can accomplish this using GPhotosApp, as getting the file by id, grabbing its blob and send the blob to Google Photos. But since I want to integrate the solution into my organization software that is hosted on my own server. I can not use Google Apps Scripts in this case, rather would rely on Google Drive & Google Photos APIs.
The overall workflow is given below:
- Locate a publicly shared file (with view access) on the users' Google Drive using get file endpoint
- Get the content of the file (Facing problem here - described below)
- Create a new file in users' Google Photos using upload_media endpoint of Photos API
- Get URL of the newly created Google Photos file (Facing problem here - described below)
I expect help with the following queries:
- Can this whole solution be implemented in Node Js using the Google Drive and Photos Node SDKs?
- When hitting Google Drive file get endpoint I get back the file metadata, and not the actual file content that I want to upload into Google Photos. On the documentation page, they say
alt=mediawould get you the file content but while trying the api call (on the documentation page), I only seejson (default) in alt parameter value. So, how can I get the publicly available file content form users' google dirve? - As demonstrated in the video, almost 900 MB file is imported instantly into Google Photos. I am not sure if this current approach (listed above) I am using will upload the file instantly or depending on file size it will take more time? For reference, file sizes can range from 2MBs - 10GBs.
- Lastly, how can I get the URL of media just uploaded in Google Photos?
Similar Resources I found on StackOverflow:
- GPhotosApp, which doesn't fullfil my requirements (as it's based on Google Apps Script)
- Google Photos API - Loading photos directly from Google Drive (No responses on this post)
I hope I am descriptive with the shared resources and information, if not I will appreciate being corrected. Also, any leads will be really appreciated.
Stay blessed.