{"action":"opened","issue":{"url":"https://api.github.com/repos/facebook-csharp-sdk/facebook-winclient-sdk/issues/86","labels_url":"https://api.github.com/repos/facebook-csharp-sdk/facebook-winclient-sdk/issues/86/labels{/name}","comments_url":"https://api.github.com/repos/facebook-csharp-sdk/facebook-winclient-sdk/issues/86/comments","events_url":"https://api.github.com/repos/facebook-csharp-sdk/facebook-winclient-sdk/issues/86/events","html_url":"https://github.com/facebook-csharp-sdk/facebook-winclient-sdk/issues/86","id":82097387,"number":86,"title":"Incorrect number of bytes sent in multipart form data when FacebookMediaObjects or FacebookMediaStreams are used","user":{"login":"0ats","id":12058212,"avatar_url":"https://avatars.githubusercontent.com/u/12058212?v=3","gravatar_id":"","url":"https://api.github.com/users/0ats","html_url":"https://github.com/0ats","followers_url":"https://api.github.com/users/0ats/followers","following_url":"https://api.github.com/users/0ats/following{/other_user}","gists_url":"https://api.github.com/users/0ats/gists{/gist_id}","starred_url":"https://api.github.com/users/0ats/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/0ats/subscriptions","organizations_url":"https://api.github.com/users/0ats/orgs","repos_url":"https://api.github.com/users/0ats/repos","events_url":"https://api.github.com/users/0ats/events{/privacy}","received_events_url":"https://api.github.com/users/0ats/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-05-28T19:49:01Z","updated_at":"2015-05-28T19:49:01Z","closed_at":null,"body":"Adding one or more FacebookMediaObjects or FacebookMediaStreams to the parameters collection of a Post method causes an extra newline (MultiPartNewLine) to be added prior to the final --boundary-- delimiter of the form data. In the case of Facebook's resumable (chunked) uploads, this causes the start_offset to be calculated incorrectly for the second chunk.\r\n\r\nRepro:\r\nPost to /videos edge with parameters {upload_phase=start, file_size=FILE_SIZE}.\r\nResult will include upload_session_id [=USID] and start_offset [= 0] for first chunk.\r\nPost first chunk of size [=FIRST_CHUNK_SIZE] to /videos edge with parameters {upload_phase=transfer, upload_session_id=USID, start_offset=0}.\r\nResult will include start_offset for second chunk equal to FIRST_CHUNK_SIZE + 2.\r\n\r\nExpected:\r\nThe result of the second call should return a start_offset of FIRST_CHUNK_SIZE.\r\n\r\nThe extra 2 bytes appears to be from an extra MultiPartNewLine (\"\\r\\n\") being added just prior to the final --boundary-- delimiter of the multipart form data. Facebook receives a chunk 2 bytes larger than what was actually sent by the user.\r\n\r\nThis appears to be happening in FacebookClient.cs:PrepareRequest() line 571 in the master branch:\r\n\r\n```java\r\nstreams.Add(new MemoryStream(Encoding.UTF8.GetBytes(string.Concat(MultiPartNewLine, MultiPartFormPrefix, boundary, MultiPartFormPrefix, MultiPartNewLine))));\r\n```"}}