Hugo Houyez Hugo Houyez - 1 year ago 91
Android Question

Upload photo to drive without compression

I want to upload a photo from my camera directly into a drive folder:

OutputStream outputStream = result.getDriveContents().getOutputStream();
ByteArrayOutputStream bitmapStream = new ByteArrayOutputStream();
/* image is my Bitmap */
image.compress(Bitmap.CompressFormat.PNG, 100, bitmapStream);

try {
} catch (IOException e1) {
Log.i(TAG, "Unable to write file contents.");

So im doing this and it's working. The problem is that my pictures in drive is in very low quality and i need to have a High Quality video.

I already tried this solution Converting bitmap to byteArray android

But then in Drive the photo wasnt recognize as media file and can't read it. I may have failed something.

EDIT: i've done exactly the same things that is there and doing this way to get my Bitmap in ActivityResult :

try {
mBitmapToSave = MediaStore.Images.Media.getBitmap(this.getContentResolver(), data.getData());
} catch (IOException e) {

Answer Source

For Get Actual Image predefined path of Captured Image using

Intent cameraIntent = new Intent(
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
this.startActivityForResult(cameraIntent, 101);  

After Captured Image you can get Captured Image on path which is set in cameraIntent. If you don't Want to set predefined path then check Intent data.

if (resultCode == && requestCode == 101) {
                try {

                    path_mm = "Onsuccess_resultcode";
                    generateNoteOnSD("photo34.txt", path_mm);
                    Bitmap photo = null;
                    if (data == null) {
                    //get Bitmap  here.
               else {
                    Uri u1 = data.getData();
                    //get uri and find actual path on that uri.
                     }catch(Exception ex)

Refer this link Upload large files to Google Drive using GD API for google drive Uploadation.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download