2016-07-11 41 views
0

我正在開發一個能夠在Dailymotion上傳視頻的網絡應用程序,所有這一切都是在1年內找到的,而且我發現最近發生的錯誤是當我上傳Dailymotion上的視頻。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檢索:

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 

我不明白爲什麼我做錯了。

我測試通過捲曲,我有同樣的錯誤。

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

修復API位DailyMotion已經改變,改變代碼builder.addPart(multipartFile.getOriginalFilename(),新FileBody(temp.toFile(), ContentType.APPLICATION_OCTET_STREAM,multipartFile.getOriginalFilename())); – malatok

回答

0

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