Downloading 'App data' files from Google Drive using the Android Drive SDK
By : Frankstan
Date : March 29 2020, 07:55 AM
will be helpful for those in need I can reproduce this when only using the drive.appdata scope. If I add another Drive scope like the drive.readonly scope it works fine. I agree this is a bug (or at least surprising behavior), so I will raise one, but please use the workaround above for now.
|
how to upload files from google drive to remote server using android app
By : Palo Juegos
Date : March 29 2020, 07:55 AM
like below fixes the issue Google Drive server cannot actively upload file to your server. Your server should have authorized Drive API to download from Google Drive. To rephrase, you can't "upload" from Drive to remote server. You should "download" from Drive to remote server. To do this, you need to authenticate your Android app to your server just like you do with web application. Then, user select file using Android UI and retrieve fileId of the file you want to download to remote server. Then, you send this fileId to your remote server with, for example, simple HTTP request. Your server will then trigger download of the file from Drive.
|
How do I access Google Drive Application Data from a remote server?
By : Leland Gayles
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Do I create a new Client ID for the server? Up to you. You don't need to, but you can. See below.
|
Get Pick Chooser Intent Google Drive File Documents Without Google Drive Api Integration in Android
By : Harshith
Date : March 29 2020, 07:55 AM
hope this fix your issue I'm working on an android app which call getPickChooserIntent in google drive to get some file, It's working fine with image but not with documents: , Finally I did it! Solution: code :
@Override
@SuppressLint("NewApi")
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE) {
if (resultCode == Activity.RESULT_OK) {
Uri mUri = CropImage.getPickImageResultUri(this, data);
writeStreamToFile(getApplicationContext(),mUri,".pdf");
}
}
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
void writeStreamToFile(Context mContext, Uri mUri,String ext) {
if (mUri == null) {
return;
}
String[] filePathColumn = {MediaStore.Images.Media.DATA};
Cursor cursor = mContext.getContentResolver().query(mUri, filePathColumn, null, null, null);
String mCurrentPath = null;
if (cursor != null && cursor.moveToFirst()) {
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
mCurrentPath = cursor.getString(columnIndex);
cursor.close();
}
if (TextUtils.isEmpty(mCurrentPath)) {
mCurrentPath = mUri.getPath();
}
File storageDir = mContext.getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS);
InputStream inputStream = null;
try {
inputStream = mContext.getContentResolver().openInputStream(mUri);
File file = File.createTempFile("pptFiles", ext, storageDir);
try (OutputStream output = new FileOutputStream(file)) {
byte[] buffer = new byte[4 * 1024]; // or other buffer size
int read;
while ((read = inputStream.read(buffer)) != -1) {
output.write(buffer, 0, read);
}
output.flush();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
|
Google Drive Android API how to upload a audio file to my drive ? How to sync drive files?
By : Vishnu
Date : March 29 2020, 07:55 AM
With these it helps I have gone through Demo's but I tried with the QuickStart example in which a image is uploaded. but I am not getting how to upload a audio file in which i will give path to my files or Intent Picker to select the file.I am using createFile() method , Try this:
|