This repository was archived by the owner on Nov 29, 2021. It is now read-only.
Fix for performing chunked upload #154
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I was trying to use the chunked upload using the StartChunkedUpload, AppendChunkedUpload, and CommitChunkedUpload methods, but it wasn't working. I wasn't getting an exception on the initial StartChunkedUpload call, but the ChunkUpload object coming back was empty, which eventually led to a null reference exception.
Using Fiddler, I looked at the request and found this call on the Create:
PUT /1/chunked_upload?oauth_consumer_key=%7Boauth_consumer_key%7D&oauth_nonce=%7Boauth_nonce%7D&oauth_token=%7Boauth_token%7D&oauth_timestamp=%7Boauth_timestamp%7D&oauth_signature=%7Boauth_signature%7D&oauth_signature_method=%7Boauth_signature_method%7D&oauth_version=%7Boauth_version%7D HTTP/1.1
which resulted in this response:
{"error": "Invalid app key (consumer key). Check your app's configuration to make sure everything is correct."}
I looked at the code and found that in both CreateChunkedUploadRequest and CreateAppendChunkedUploadRequest, several oauth parameters were being added to the request, but that they weren't being populated. It didn't look like these oauth parameters were present in other similar calls so I didn't think they were necessary. I ended up removing them and the chunked upload then worked.
On create, my request looked like this:
PUT /1/chunked_upload HTTP/1.1
And my response like this:
{"expires": "Wed, 18 May 2016 21:14:19 +0000", "upload_id": "AAAAAAAAAdGk8g0SdUJBLQ", "offset": 4194304}
I was then able to make an append request like this:
PUT /1/chunked_upload?upload_id=AAAAAAAAAdGk8g0SdUJBLQ&offset=4194304 HTTP/1.1