Reputation: 41
I want to convert video file to base64 string and vice versa currently my video is inside raw folder .This is my code :
String uriPath = "android.resource://com.hello.videouploaddemo/raw/sendvideo";
Upvotes: 1
Views: 7515
Reputation: 11
First convert the raw file into a byte[]
InputStream inStream = context.getResources().openRawResource(R.raw.sendvideo);
byte[] video = new byte[inStream.available()];
Use the Android Base64
Class
public static byte[] encode (byte[] input, int flags)
byte[] base64 = Base64.encode(video,Base64.DEFAULT);
public static byte[] decode (byte[] input, int offset, int len, int flags)
byte[] rowVideoAgain = Base64.decode(base64,0,base64.length,Base64.DEFAULT);
http://developer.android.com/reference/android/util/Base64.html
You should start this in a AsyncTask http://developer.android.com/reference/android/os/AsyncTask.html
Upvotes: 1