【问题标题】:Dailymotion upload error "no content"Dailymotion 上传错误“无内容”
【发布时间】:2016-07-12 00:39:14
【问题描述】:

我正在开发一个能够在 Dailymotion 上上传视频的网络应用程序,所有这些都是在 1 年内发现的,我最近在 Dailymotion 上上传视频时发现了一个错误。

{
"error": "missing content"
"seal": "540f4ad5a0f9c6a7e85a46be98361581"
}

我使用 java 和 lib“org.apache.http”来调用 dailymotion。

我的代码如下所示:

Path temp = Files.createTempFile(multipartFile.getName(), "." + suffix);
            multipartFile.transferTo(temp.toFile());
            MultipartEntityBuilder builder = MultipartEntityBuilder.create();
            builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
            builder.addPart(multipartFile.getOriginalFilename(), new FileBody(temp.toFile(),
                    ContentType.APPLICATION_OCTET_STREAM, multipartFile.getOriginalFilename()));
            httpPost.setEntity(builder.build());
            try (CloseableHttpClient httpclient = HttpClients.createDefault();
                    CloseableHttpResponse response = httpclient.execute(httpPost);) {
                HttpEntity entity = response.getEntity();
                ObjectMapper mapper = new ObjectMapper();
                DailymotionUploadVideoResponse dmUploadResponse = mapper.readValue(entity.getContent(),
                        DailymotionUploadVideoResponse.class);
                // Delete temp file after upload
                Files.deleteIfExists(temp);
                if (dmUploadResponse.getError() != null) {
                    throw new DailymotionJsonException(dmUploadResponse.getError().getMessage());
                }
                EntityUtils.consume(entity);
                response.close();

通过dailymotion检索网址上的POST:

http://upload-12.dc3.dailymotion.com/upload?uuid=035e365c5b2355616e381f43c1b2b391&seal=edad1d3ad9e348c65e975582571e5815

POST 请求的标头:

Content-Disposition:
form-data; 
name="2015-07-16-192550-1.webm"; 
filename="2015-07-16-192550-1.webm", 
Content-Type: application/octet-stream, 
Content-Transfer-Encoding: binary

我不明白为什么我做错了。

我通过 curl 测试,我有同样的错误。

Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryImx1443wQZZBF0Fb
Content-Length: 1398401
Source message

POST /upload?uuid=035e365c5b2355616e381f43c1b2b391&seal=edad1d3ad9e348c65e975582571e5815 HTTP/1.1
 HOST: upload-12.dc3.dailymotion.com
 content-type: multipart/form-data; boundary=----WebKitFormBoundaryImx1443wQZZBF0Fb
 content-length: 1398401

 ------WebKitFormBoundaryImx1443wQZZBF0Fb
 Content-Disposition: form-data; name="2015-07-16-192550-1.webm"; filename="2015-07-16-192550-1.webm"
 Content-Type: video/webm

【问题讨论】:

  • 修复 API dailymotion 已更改,更改代码 builder.addPart(multipartFile.getOriginalFilename(), new FileBody(temp.toFile(), ContentType.APPLICATION_OCTET_STREAM, multipartFile.getOriginalFilename()));跨度>

标签: java dailymotion-api


【解决方案1】:

API dailymotion已经改变,改变代码

builder.addPart(multipartFile.getOriginalFilename(), new FileBody(temp.toFile(),
                    ContentType.APPLICATION_OCTET_STREAM, multipartFile.getOriginalFilename()));

作者:

builder.addPart("file", new FileBody(temp.toFile(),
                        ContentType.APPLICATION_OCTET_STREAM, multipartFile.getOriginalFilename()));

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-08-08
    • 1970-01-01
    • 2020-10-25
    • 2014-12-16
    • 1970-01-01
    • 1970-01-01
    • 2011-05-16
    相关资源
    最近更新 更多