Upload a file on macOS with NSURLSession
I'm trying to upload a file on macOS using an NSURLSessionUploadTask but keep running against a wall. Even though all seems to be fine and set according to specs I keep getting an Http status 400 "API upload did not contain a file part".
The curl example from the api docs works perfectly so I assume there is some incompatibility as to how NSURLSession uploads the files as part of a multipart/form-data POST request which the API endpoint doesn't seem to support.
I use basically the same code for uploading files to Google Drive and it works just fine there, so I don't think it's an error on my part.
Any help would be greatly appreciated...
headers as returned by httpbin.org:
"form": {
"attributes": "{\"name\":\"localhost.zip\", \"parent\":{\"id\":\"<folderid>\"}}"
},
"headers": {
"Accept": "*/*",
"Authorization": "Bearer <token>",
"Content-Length": "1569178",
"Content-Type": "multipart/form-data; boundary=------------------------52ac5dd531376fde",
"Host": "httpbin.org",
"User-Agent": "curl/7.79.1",
},
投稿コメントは受け付けていません。
コメント
0件のコメント