我正在开发一个实用程序来使用以下过程上传和连接最多 20 张照片:
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
我发现第 3 步有时会因某些照片尚未完成处理的错误而失败。所以我在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
我发现在 photo.get 成功之前,通常需要在步骤 3 中重试五 (5) 次 5 秒(总共 25 秒)。但是,第 4 步有时仍会失败,并出现 Photo(n) 不存在的错误。
如果我删除照片并重复测试,有时它会成功,有时它会失败。
是什么导致 photos.batchUpdate 间歇性失败,我可以在步骤 3 中使用什么方法来确保所有照片都已完成初始处理并且可以在步骤 4 中成功更新?
谢谢