gphotosuploader | Unofficial Google Photos uploader and Go library | File Upload library
kandi X-RAY | gphotosuploader Summary
kandi X-RAY | gphotosuploader Summary
Google Photos does not have a desktop uploader for Linux, ~~neither an API to upload a photo programmatically.~~ (now there is an Official Google Photos API). G Photos Uploader lets you upload photos from Linux (and, in theory, any OS for which you can compile a Go program) specifying the file name or watching a directory for changes. Furthermore, the project can also be used as a library that you can include in other Go programs.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- CreateAlbum creates a new album
- initAuthentication initializes the authentication cookie credentials .
- Main entry point for image upload
- EnqueueUpload enqueues a file at the specified path .
- handleFileChange is called when a file change occurs .
- StartWebDriverCredentialsWizard will start the web browser for the web browser
- handleUploaderEvents handles uploader events .
- Parse CLI arguments
- instructUserAndWaitForLogin waits for the user to complete .
- NewUpload creates a new Upload .
gphotosuploader Key Features
gphotosuploader Examples and Code Snippets
Community Discussions
Trending Discussions on gphotosuploader
QUESTION
I'm developing this CLI to upload images to Google Photos. The CLI creates several go routines to upload files in parallel 1. Once it's uploaded, the same routine adds it to an Album
. These albums are created if they didn't exist before 2.
Due to the concurrency and the fact that Google Photos API allows the creation of two Albums
with the same name, I'm having duplicated album names that I'd like to avoid.
The GetOrCreateAlbumByName()
3 doesn't ensure that the Album
is unique. It basically ask if an album exists with the same name and if not, it will create a new one. But this function could be called in parallel so two Album
with the same name could be created. Besides it's implementing a mutex, I'm observing duplicates.
How would yo recommend to deal with that?
- Create a Worker (like a microservice) that deal with album creation. Each go routine will be blocked until the album is created. It will remove concurrency on the
Album
creation part. - Maintain an album cache and use it to check if the album has been already created. In that case, race condition could happen too, but with less probability.
- Using 1 and 2 together.
- Other, please specify.
I have concerns about 1, 2 and 3... that's why I would like to know how you would deal with that.
Thanks in advance
...ANSWER
Answered 2020-Aug-07 at 07:47You use Client.GetOrCreateAlbumByName()
to get or create albums. This method is safe for concurrent use, and it uses a mutex internally to serialize calls, which ensures duplicates are not created.
However, you are creating and using multiple clients here, which means concurrent calls to all of them is not serialized, only concurrent calls to individual clients.
So the solution to either use a single client, then all calls will be serialized, or if that's not possible, you have to serialize calls to all clients, e.g. using a single mutex or other means.
An example how to serialize calls to all clients with a mutex:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install gphotosuploader
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page