How To Get The File Id So I Can Perform A Download Of A File From Google Drive Api On Android?
Solution 1:
In my opinion the easiest and fastest way to get a Google Drive file ID is from Google Drive on the web. Right-click the file name and select Get shareable link. The last part of the link is the file ID. Then you can cancel the sharing.
Solution 2:
This script logs all the file names and ids in the drive:
// Log the name and id of every file in the user's Drivefunction listFiles() {
var files = DriveApp.getFiles();
while ( files.hasNext() ) {
var file = files.next();
Logger.log( file.getName() + ' ' + file.getId() );
}
}
Also, the "Files: list" page has a form at the end that lists the metadata of all the files in the drive, that can be used in case you need but a few ids.
Solution 3:
Well the first option I could think of is that you could send a list
request with search parameters for your file, like title="File_1.xml" and fileExtension="xml"
. It will either return an empty list of files (there isn't one matching the serach criteria), or return a list with at least one file. If it's only one - it's easy. But if there are more - you'll have to select one of them based on some other fields. Remember that in gdrive you could have more than 1 file with the same name. So the more search parameters you provide, the better.
Solution 4:
Click with the right mouse button on the file in your Google Drive. Choose the option to get a link which can be shared from the menu. You will see the file id now. Don't forget to undo the share.
Solution 5:
One way is to associating unique properties with your file while creation.
properties = "{ \
key='somekey' and \
value='somevalue'
}"
then create a query.
query ="title = "+"\'"+ title +"\'"+ \
AND+"mimeType = "+"\'"+ mimeType +"\'"+ \
AND+"trashed = false"+ \
AND+"properties has "+ properties
All the file properties(title, etc) already known to you can go here + properties.
Post a Comment for "How To Get The File Id So I Can Perform A Download Of A File From Google Drive Api On Android?"