Я должен загрузить аудиофайл 3gp на свой сервер, используя MultipartEntity.Я использую этот код, но все еще не могу загрузить 3gp файл.
FileInputStream is = new FileInputStream(new File(Environment.getExternalStorageDirectory().getAbsolutePath()+
"/" + nameOfFile));
byte[] data = IOUtils.toByteArray(is);
InputStreamBody isb = new InputStreamBody(new
ByteArrayInputStream(data),nameOfFile);
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.****.com/places/uploadVideo");
httppost.setHeader("Content-Type", "audio/3gpp");
MultipartEntity multipartContent = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
multipartContent.addPart("video", isb);
Log.d("Audio length", isb.getFilename()+" "+isb.getMediaType()+ isb.getMimeType());
httppost.setEntity(multipartContent);
HttpResponse res =httpclient.execute(httppost);
InputStream input = res.getEntity().getContent();
BufferedReader rd = new BufferedReader(new InputStreamReader(input,"UTF-8"),input.toString().length());
String line;
StringBuilder sb = new StringBuilder();
while ((line = rd.readLine()) != null) {
sb.append(line);
}
rd.close();
String uploadresponse = sb.toString();
Log.d("Upload Pic Response",uploadresponse );
Пожалуйста, подскажите, где я совершаю ошибку?
LogCat Response
<code> 02-18 19:58:51.912: D/Audio length(3157): 1329575327359.3gp applicationapplication/octet-stream
02-18 19:58:52.412: D/dalvikvm(3157): GC_FOR_MALLOC freed 2359 objects / 161592 bytes in 56ms
02-18 19:58:54.002: I/Resources(3157): Loaded time zone names for en_US in 200ms.
02-18 19:58:54.012: D/Upload Pic Response(3157): <strong>app/controllers/places_controller.php</strong> (line <strong>425</strong>)<pre class="cake-debug">Array( [controller] => places [action] => uploadVideo [named] => Array ( ) [pass] => Array ( ) [plugin] => [form] => Array ( ) [url] => Array ( [url] => places/uploadVideo ))
{"response":{"status": 0, "mesg": "Нет видеоданных в запросе"}, "data": null}