I have tried uploading an audio file from android to node.js server,but unfortunately file uploaded in the server is not playing. It shows the error "No suitable decoder module: VLC does not support the audio or video format 'samr'" while playing in VLC media player.
This is my Android code:
String name = aurl[0];
String groupid = aurl[0];
File file = new File(aurl[1]);
//ByteArrayBody byteArrayBody = new ByteArrayBody(audioData, name);
MultipartEntity multipartEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
//multipartEntity.addPart("uploadDocument", byteArrayBody);
ContentBody cb = new FileBody(file,"video/mp4");
multipartEntity.addPart("uploadDocument",cb);
HttpClient httpClient = new DefaultHttpClient();
System.out.println("Befor Call ...................................");
String requestUri = Constants.URI_SERVER + "/upload/"+ groupid +"/FromAndroidkycUploadingAudio";
HttpPost httpPost = new HttpPost(requestUri);
httpPost.setEntity(multipartEntity);
Header header = new BasicHeader(Constants.FIELD_REQUEST_SOURCE, Constants.FIELD_ANDROID);
httpPost.addHeader(header);
HttpResponse httpResponse = httpClient.execute(httpPost);
if(httpResponse.getStatusLine().getStatusCode() == 200) {
toastMsg = Constants.MSG_UPLOAD_SUCCESS;
} else {
toastMsg = Constants.MSG_UPLOAD_FAILURE;
}
My server side Node.js Code:
var fs1=require('fs');
var util = require('util');
var is = fs1.createReadStream(req.files.uploadDocument.path)
var os = fs1.createWriteStream("client_documents/"+"Audio1"+".mp4");
util.pump(is, os, function() {
//fs1.unlinkSync(req.files.uploadDocument.path);
console.log('It\'s moved!');
});
Please suggest me any solution...