YouTube API v2.0 – Resumable Uploadsを使用して、Android アプリケーションから YouTube に動画をアップロードしようとしています。
これを使用して 2 つの手順を正常に完了しましたが、手順 2 で取得した URL の場所に実際のビデオをアップロードする必要がある 3 番目の手順で、エラー メッセージが表示されます。
Content-Type application/x-www-form-urlencoded は有効な入力タイプではありません。
次のプロトコルを使用して put リクエストを送信しています。
PUT <upload_url> HTTP/1.1
Host: uploads.gdata.youtube.com
Content-Type: <video_content_type>
Content-Length: <content_length>
<Binary_file_data>
このコードを使用して:
HttpPut put=new HttpPut(location);
InputStream is = new FileInputStream(video_file);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] b = new byte[(int) length];
int bytesRead;
while ((bytesRead = is.read(b)) != -1) {
bos.write(b, 0, bytesRead);
}
byte[] bytes = bos.toByteArray();
// ContentType type=
ByteArrayEntity byte_entity=new ByteArrayEntity(bytes);
byte_entity.setContentType("video/3gpp");
put.setEntity(byte_entity);
HttpResponse upload_response = client.execute(put);
MultipartEntity を使用してリクエストを送信しようとしましたが、毎回同じエラーが発生しますContent-Type application/x-www-form-urlencoded is not a valid input type.