Where did the “createFromResourceId()” go?

I tested Burcu’s answer, and unfortunately it did not work. Or maybe I phrased the question incorrectly. I’ll try to re-phrase it (and I found the correct answer).

There are 2 different string type ID representations available for DriveId (both file and folder).

1/ DriveId.encodeToString(), resulting in something like:
"DriveId:CAESHDBCMW1RVVcyYUZKZmRhakIzMDBVbXMYjAUgssy8yYFRTTNKRU55"
2/ and DriveId.getResourceId(), resulting in shorter:
"UW2aFJfdajB3M3JENy00Ums0B1mQ"

In 4.1, there were 2 methods that would turn these back to the DriveId

1/ DriveId.decodeFromString(DriveId.encodeToString());
2/ DriveId.createFromResourceId(DriveId.getResourceId());

Both of them worked correctly in pairs and I chose the ResourceId variety, since this short string appears in http address used in other systems (Apps Script…). For example:
https://docs.google.com/file/d/UW2aFJfdajB3M3JENy00Ums0B1mQ
Also, it appears to be persistent even if the file is manipulated in Google Drive (trashed, restored, moved).

But in 4.2, the createFromResourceId() disappeared and CAN NOT be replaced by “decodeFromString()” like this:

//INCORRECT    
DriveId.decodeFromString(DriveId.getResourceId());

Instead, the DriveId from ResourceId has to be retrieved this way:

DriveIdResult result = Drive.DriveApi.fetchDriveId(GAC, DriveId.getResourceId()).await();
DriveId drvID = result.getDriveId();

(and I use the “await” version for simplicity).

So the conclusion is:
The createFromResourceId() was replaced by

Drive.DriveApi.fetchDriveId(GAC, DriveId.getResourceId()).await().getDriveId()

with the caveat that the “await()” construct should be implemented as a callback in normal UI thread.

UPDATE (2014-10-23)

The answer above is quite stale, please refer to the comments below.

Leave a Comment