Update uploadWithRetries to return the response object if there was an error

This allows callers to examine the response object and determine how to handle the error