1

I am trying to pass the recorded video file saved in /storage/emulated/0/Videos/someVideo.3gp in android to remote server through POST HTTP method. I used this as a way to pass video file to remote server in FileBody format. But, at the end when I am trying to execute httpClient.execute(request) command it just keep throwing FileNotFoundException.

So, I don't understand why the video file is not accessible to outside world since I had saved it to sdcard using getExternalStorageDirectory(). I also had added write permissions to manifest file.

P.S. I am using Nexus 7 to test this. Please help..

Thanks in advance!

Community
  • 1
  • 1
Sheetal Jadhwani
  • 75
  • 1
  • 3
  • 9

1 Answers1

1

Are you checking the existence of file before executing the httpClient.execute(request) ?

Referenced from the question that you are following:

File sourceFile = new File(sourceFileUri);
if (!sourceFile.isFile()) {
Log.e("Huzza", "Source File Does not exist");
return 0;
}

EDIT:
May be you are not converting the Path from Uri correctly on onActivityResult(...) method I am sharing the code for getting correct path and it is working nicely in my Application.

String videoPath = "";
try 
{ 
 String[] filePathColumn = { MediaStore.Video.Media.DATA };
 Cursor cursor = getContentResolver().query(selectedVideoUri,
 filePathColumn, null, null, null);
 cursor.moveToFirst();
 int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
 videoPath = cursor.getString(columnIndex);
 cursor.close();
} catch (Exception e) {
 Log.e(TAG,
 "Error parsing Video path = " + e.toString());
}
Salman Khakwani
  • 6,684
  • 7
  • 33
  • 58
  • 1
    I added the check now..And, the file doesn't exists. However, I don't know the reason for the error. Since I am getting the filePath returned by the intent after video recording is done.. – Sheetal Jadhwani Jul 18 '13 at 00:20
  • 1
    Thank you for pointing out the issue in my implementation. Earlier I was actually trying to save the recorded video in custom folder in sdcard and hence it wasn't working. But when I tried your code and saved it to its default location it worked..! Thanks.. – Sheetal Jadhwani Jul 18 '13 at 17:13