- A folder is a file with the MIME type
application/vnd.google-apps.folder
and with no extension. - You can use the alias
root
to refer to the root folder anywhere a file ID is provided - To insert a file in a particular folder, specify the correct ID in the parents property of the file.
- The parents property can be used when creating a folder as well to create a subfolder.
- To add or remove parents for an exiting file, use the
addParents
andremoveParents
query parameters by callingPATCH https://www.googleapis.com/drive/v3/files/${fileId}
- When creating a batch of files, you can preallocate up to 1,000 UUIDs for use in create requests by calling
GET https://www.googleapis.com/drive/v3/files/generateIds?count=${count}&space=drive
This does not work when copying files. - All you need is the
fileId
to copy a file. It does not matter whether or not the document was created by a user of the destination Google Apps domain.
- When copying files, you can blow out the default visibility setting set by the Google Apps administrator using an optional query parameter
?ignoreDefaultVisibility=true
. - When sharing you can disable notification e-mails by:
?sendNotificationEmail=false
. Important: you cannot disable notification e-mails when transferring ownership. - To transfer ownership, use the optional query parameter
?transferOwnership=true
// PHP: Unofficial, extracts the fileId from a Google Drive/Docs URL
function getFileIdFromUrl($url) {
preg_match('/(?P<fileId>[-\w]{25,})/', $url, $matches);
return $matches['fileId'];
}
// JavaScript: Unofficial, extracts the fileId from a Google Drive/Docs URL
function getFileIdFromUrl(url) {
return url.match(/[-\w]{25,}/);
}