The completeHttpUpload() in the cloud data store backends can be improved in terms of quantity of cloud storage service API calls.
- Try a single getRecord() call at the beginning instead of calling exists(). If an exception is thrown, catch it - this means the record doesn't exist and can be written. If a record is returned, we don't write - and instead return this record.
- Don't check for existence after writing the record; instead assume that the record is written correctly if no error or exception from SDK. Verify this behavior in unit tests.
- After writing the record, construct the record directly instead of calling getRecord() to do it.
This removes two network API calls if the record is written and one if the record already exists.