DailyMotion上传API丢失文件错误

时间:2014-05-19 15:26:21

标签: dailymotion-api

我正在尝试将mp4视频上传到DailyMotion上传API。当我发送文件内容时,我收到如下错误响应。

Id = 31, Status = RanToCompletion, Method = "{null}", 
Result = "{\"error\":\"missing file\",\"seal\":\"4a24a4c8a51771d9d3b8bcd4462e721b\"}"

我在.net 4.5中使用C#并生成以下调用:

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]]]

我已成功使用DailyMotion的CURL示例上传。使用Fiddler,CURL生成以下内容:

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]]

文件二进制文件看起来不错,我看到的唯一区别是连接和用户代理标头。研究Connection头,看起来像HTTP / 1.1不需要Keep-Alive。我尝试了几种不同的用户代理(Mozilla,CURL,IE)但响应没有变化。

我很欣赏任何有关正在发生的事情的见解。 谢谢!

编辑补充代码:

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();

        }
    }

编辑更新了以下帮助

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--

编辑:请求了修复程序的代码示例。它如下:

videoContent.Headers.ContentDisposition.FileName = "\"" + name + "\"";

1 个答案:

答案 0 :(得分:2)

经过调查,看起来负责处理文件上传的 nginx-upload-module 看起来并不理解HTTP标头中引用的内容边界,{{3无论如何,它不是在HTTP中定义边界的标准方法。看起来您用来制作请求的C#库可能遵循multipart/digest内容类型的标准而不是multipart/form-data(参见第7.2.4节)。请检查这是否是您可以控制的,然后重新测试。