Dean Z
Dean Z

Reputation: 17

How to determine when a newly created Photo can be updated?

I am developing a utility to upload and connect a series of up to 20 Photos using the following process:

 1. For each Photo:
    - call photo.startUpload method
    - upload Photo
    - call photo.create method
    - store received PhotoId

 2. Create updatePhotosRequest:
    - Photos are connected in the sequence:
        * PhotoId(1) <=> PhotoId(2) <=> ... <=> PhotoId(n-1) <=> PhotoId(n)
    - Targets are PhotoIds received in step 1
    - updateMask = "connections"

 3. Create connections:
    - call photos.batchUpdate method

I found that Step 3 would sometimes fail with an error that some of the Photos had not finished processing. So I added a step before the photos.batchUpdate.

 1. For each Photo:
    - call photo.startUpload method
    - upload the Photo
    - call photo.create method
    - store received PhotoId

 2. Create updatePhotosRequest:
    - Photos are connection in sequence:
        * PhotoId(1) <=> PhotoId(2) <=> ... <=> PhotoId(n-1) <=> PhotoId(n)
    - Targets are PhotoIds received in step 1
    - updateMask = "connections"

 3. Check for Photo(n) completion:
    - call photo.get method for PhotoId(n)
    - if photo.get returns an error, wait 5 secs and retry
    - if photo.get returns success, continue to next step

 4. Create connections:
    - call photos.batchUpdate method

I found that it typically would require five (5) 5-sec retries (total of 25 secs) in step 3 before the photo.get would succeed. However, Step 4 will still sometimes fail with an error that Photo(n) does not exist.

If I delete the Photos and repeat the test sometimes it would succeed and sometimes it would fail.

What is causing the photos.batchUpdate to intermittently fail and what method can I use in step 3 to ensure that all Photos have finished initial processing and can be updated successfully in step 4?

Thank you

Upvotes: 0

Views: 97

Answers (1)

Guilherme Ribas
Guilherme Ribas

Reputation: 21

Google requires some time to process the photos, something between 0 and 30 seconds. There is a way to check if an image is already available using https://streetviewpublish.googleapis.com/v1/photo/:photoId if available it will return 200, if not will throw an error returning 503.

edit: You have to pass a param called view. you can set view: "BASIC"

Upvotes: 0

Related Questions