I'm using OkHttp to upload files to Google Cloud Storage. Right now, I'm doing a single PUT request with a custom request body and stream the data. The request is something like this:
final Request request = new Request.Builder()
.url(uploadUrl)
.put(requestBody)
.addHeader("Content-Length", length)
.addHeader("Content-Range", range)
.build();
My requestBody
handles reading of the file and writing to the BufferedSink
, similar to the recipe for Post Streaming available here (https://github.com/square/okhttp/wiki/Recipes):
Will it be faster to move to uploading Multiple Chunks (as described here: https://cloud.google.com/storage/docs/json_api/v1/how-tos/resumable-upload#upload-resumable - I think it should be achievable with OkHttp MultipartBody.Builder
), or should I stick with streaming?