I'm working on a project where I need to upload a file to google Drive, to download it with another app.
I wanted to use the Drive Id, which I get by creating a file, to find it later, but this seems not to work.
I used an example from Google to get the ID:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case REQUEST_CODE_CREATOR:
if (resultCode == RESULT_OK) {
driveId = data.getParcelableExtra(
OpenFileActivityBuilder.EXTRA_RESPONSE_DRIVE_ID);
showMessage("File created with ID: " + driveId);
}
break;
default:
super.onActivityResult(requestCode, resultCode, data);
break;
}
}
This seemed to work so far, I am getting the Drive ID.
After this, I wanted to test it by using the Example "Files: get" from the Google Developers-page, where I got the following error:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "notFound",
"message": "File not found: CAESABiCASCQ1OnN-VMoAA==",
"locationType": "other",
"location": "file"
}
],
"code": 404,
"message": "File not found: CAESABiCASCQ1OnN-VMoAA=="
}
}
It seems like this ID is not the id to find files.
There must be something I missed but i don't know what.
I am new to programming, especially to Google and Android and I would be very happy if any one can help me through their answers.
Thanks.
There are two problems with your approach.
1/ You can not use the DriveId for anything outside your Android App instance, you have to go for the ResourceId (see SO 32210970)
2/ The DriveId you're showing above is the 'preliminary' DriveId that is returned by GooPlaySvcs before the object is committed (uploaded) (see SO 22874657). Also, you can't get a valid ResourceId until it the object is committed.
See also SO 33355665, SO 29030110
If you intent to take the ResourceId 'outside' (to a different app), you'll be OK. If you decide to use this ResourceId in the same Android app, mixing the two Apis (GDAA and REST), you will potentially introduce latency issues, since GDAA is a 'buffering' layer between your app and the REST api (you've already run into one with your 'invalid' DriveId).
Good Luck