Quantcast
Channel: Latest Questions by renezuidhof
Viewing all articles
Browse latest Browse all 28

Content-Length mismatch: Request Header indicated x bytes, but client sent 0 bytes.

$
0
0
I have been working some code to upload a file to SoundCloud with the WWW class (http://answers.unity3d.com/questions/966993/www-wwwform-and-soundcloud.html). I can't get it to work so i started the thread in the link above. Now after some more investigation it seems that the problem is that the WWW class is not sending the files i add with wwwform.AddBinaryData. Does someone know what i am doing wrong? public IEnumerator UploadFileWebClient(FileInfo file) { //Started as Coroutine ServicePointManager.Expect100Continue = false; byte[] fileContents = File.ReadAllBytes(file.FullName); WWWForm form = new WWWForm(); form.AddField("track[title]", "Some title"); form.AddField("track[sharing]", "private"); form.AddField("oauth_token", soundCloudToken); form.AddField("format", "json"); form.AddBinaryData("track[asset_data]", fileContents, file.FullName, "multipart/form-data"); //Also tried "application/octet-stream" WWW download = new WWW("https://api.soundcloud.com/tracks", form); yield return download; if(!string.IsNullOrEmpty(download.error)) { Debug.Log ( "Error downloading: " + download.error ); } else { Debug.Log(download.text); } }

Viewing all articles
Browse latest Browse all 28

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>