Reputation: 13
I am trying to upload an mp4 video to the DailyMotion Upload API. When I send the file content, I receive an error response as below.
Id = 31, Status = RanToCompletion, Method = "{null}",
Result = "{\"error\":\"missing file\",\"seal\":\"4a24a4c8a51771d9d3b8bcd4462e721b\"}"
I am using C# in .net 4.5 and have generated the following calls:
POST [[UPLOAD URL]] HTTP/1.1
Accept: */*
Content-Type: multipart/form-data; boundary="c83ccd81-39f7-4167-a8f1-74ab63eb4219"
Host: upload-01.sv6.dailymotion.com
Content-Length: 9893501
Expect: 100-continue
--c83ccd81-39f7-4167-a8f1-74ab63eb4219
Content-Disposition: form-data; name="file"; filename="TESTFILE.mp4"
Content-Type: application/octet-stream
[[[FILE BINARY]]]
I have successfully uploaded using DailyMotion's CURL sample. Using Fiddler, CURL generates the following:
POST [[UPLOAD URL]] HTTP/1.1
User-Agent: curl/7.33.0
Host: upload-02.sv6.dailymotion.com
Accept: */*
Connection: Keep-Alive
Content-Length: 9893509
Expect: 100-continue
Content-Type: multipart/form-data; boundary=------------------------a49610ec11411f2a
--------------------------a49610ec11411f2a
Content-Disposition: form-data; name="file"; filename="TESTFILE.mp4"
Content-Type: application/octet-stream
[[FILE BINARY]]
The file binary looks good and the only differences I see are the connection and User-Agent headers. Researching the Connection header, it looks like Keep-Alive is unnecessary with HTTP/1.1. I have tried several different User-Agents (Mozilla, CURL, IE) but no change in response.
I appreciate any insight into what is happening. Thank you!
EDIT Added code:
mediatype = "video/mp4"
name = "file"
filename = "file"
data = {byte[9893291]}
public async Task UploadRequest(string mediatype, string name, string filename, byte[] data)
{
using(HttpClient httpClient = new HttpClient())
{
var requestContent = new MultipartFormDataContent();
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("*/*"));
var videoContent = new ByteArrayContent(data);
videoContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data");
videoContent.Headers.ContentDisposition.Name = "\"file\"";
videoContent.Headers.ContentDisposition.FileName = filename;
videoContent.Headers.ContentType = MediaTypeHeaderValue.Parse("application/octet-stream");
requestContent.Add(videoContent, name);
Apirequest.HttpRequestMessage.Content = requestContent;
Apirequest.HttpResponseMessage = httpClient.SendAsync(Apirequest.HttpRequestMessage).Result;
Apirequest.HttpResponseMessage.EnsureSuccessStatusCode();
}
}
EDIT Updated following help
POST http://upload-02.nyc.dailymotion.com/upload?uuid=c8542d0a9be73c55fbace1ee4aa1744b&seal=4770461f7f07b4e0c15750d70bc44377 HTTP/1.1
Accept: */*
Content-Type: multipart/form-data; boundary=62fcae82-e1b2-4df3-99c4-90fad29be62d
Host: upload-02.nyc.dailymotion.com
Content-Length: 9893493
Expect: 100-continue
--62fcae82-e1b2-4df3-99c4-90fad29be62d
Content-Disposition: form-data; name="Testfile.mp4"; filename=Testfile.mp4
Content-Type: application/octet-stream
���ftypmp42���mp41mp42isom���wide���mdat!�@h!
�Ќ>��SZa��x�M�SZa��{�!
�ˊ��]C���I��x�8V]�F}=�_Pc1�w�d>��.�!
������hRDq��0�`D�4�QG��A��nn��û�6��ݳ���ι�τpE����s���8)�=����^�ʇ�/�N8k.��]Jr)�z���pTR�
=}.�!
[[FILE GOES ON]]
ðb ’h 'v† )ˆI 7| F3• Ršv _Ê0 kC yDÀ ‚¡] ‰¢ h ŽÂi /
×ÿ ¥ Ó
‘`Q ‘É ’Ö ’K ’Õ ’ÿ\ “ˆŠ “³Â ”"G ”7» +udta #titl ÇTestFile
--62fcae82-e1b2-4df3-99c4-90fad29be62d--
EDIT: A code example of the fix was requested. It is as follows:
videoContent.Headers.ContentDisposition.FileName = "\"" + name + "\"";
Upvotes: 1
Views: 1331
Reputation: 1596
After investigation, it looks like the nginx-upload-module that is responsible for handling file uploads on our side doesn't understand quoted content boundaries in HTTP headers, which, according to the RFC1341, is not the standard way of defining boundaries in HTTP anyway. It looks like the C# library you are using to craft your request may be following the standard for the multipart/digest
content type instead of the multipart/form-data
(cf section 7.2.4). Please check whether this is something you have any control on or not and test again.
Upvotes: 2