Я разрабатываю веб-приложение, способное загружать видео на Dailymotion, все было найдено в течение 1 года, и я недавно видел ошибку, когда я загружаю видео на Dailymotion.Ошибка при отправке Dailymotion «no content»
{
"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();
POST на URL получить на 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
Я не понимаю, почему я делаю неправильно.
Я проверяю через 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
Fix API Dailymotion изменились, изменить код builder.addPart (multipartFile.getOriginalFilename(), новый FileBody (temp.toFile(), ContentType.APPLICATION_OCTET_STREAM, multipartFile.getOriginalFilename())); – malatok