// Before running the sample:
// - Enable the API at:
// https://console.developers.google.com/apis/api/drive.googleapis.com
// - Login into gcloud by running:
// `$ gcloud auth application-default login`
// - Install the npm module by running:
// `$ npm install googleapis`
const {google} = require('googleapis');
const drive = google.drive('v2');
async function main() {
const auth = new google.auth.GoogleAuth({
// Scopes can be specified either as an array or as a single, space-delimited string.
scopes: [
'https://www.googleapis.com/auth/drive',
'https://www.googleapis.com/auth/drive.appdata',
'https://www.googleapis.com/auth/drive.apps.readonly',
'https://www.googleapis.com/auth/drive.file',
],
});
// Acquire an auth client, and bind it to all future calls
const authClient = await auth.getClient();
google.options({auth: authClient});
// Do the magic
const res = await drive.files.trash({
// The ID of the file to trash.
fileId: 'placeholder-value',
// Specifies which additional view's permissions to include in the response. Only 'published' is supported.
includePermissionsForView: 'placeholder-value',
// Whether the requesting application supports both My Drives and shared drives.
supportsAllDrives: 'placeholder-value',
// Deprecated use supportsAllDrives instead.
supportsTeamDrives: 'placeholder-value',
});
console.log(res.data);
// Example response
// {
// "alternateLink": "my_alternateLink",
// "appDataContents": false,
// "canComment": false,
// "canReadRevisions": false,
// "capabilities": {},
// "contentRestrictions": [],
// "copyRequiresWriterPermission": false,
// "copyable": false,
// "createdDate": "my_createdDate",
// "defaultOpenWithLink": "my_defaultOpenWithLink",
// "description": "my_description",
// "downloadUrl": "my_downloadUrl",
// "driveId": "my_driveId",
// "editable": false,
// "embedLink": "my_embedLink",
// "etag": "my_etag",
// "explicitlyTrashed": false,
// "exportLinks": {},
// "fileExtension": "my_fileExtension",
// "fileSize": "my_fileSize",
// "folderColorRgb": "my_folderColorRgb",
// "fullFileExtension": "my_fullFileExtension",
// "hasAugmentedPermissions": false,
// "hasThumbnail": false,
// "headRevisionId": "my_headRevisionId",
// "iconLink": "my_iconLink",
// "id": "my_id",
// "imageMediaMetadata": {},
// "indexableText": {},
// "isAppAuthorized": false,
// "kind": "my_kind",
// "labels": {},
// "lastModifyingUser": {},
// "lastModifyingUserName": "my_lastModifyingUserName",
// "lastViewedByMeDate": "my_lastViewedByMeDate",
// "linkShareMetadata": {},
// "markedViewedByMeDate": "my_markedViewedByMeDate",
// "md5Checksum": "my_md5Checksum",
// "mimeType": "my_mimeType",
// "modifiedByMeDate": "my_modifiedByMeDate",
// "modifiedDate": "my_modifiedDate",
// "openWithLinks": {},
// "originalFilename": "my_originalFilename",
// "ownedByMe": false,
// "ownerNames": [],
// "owners": [],
// "parents": [],
// "permissionIds": [],
// "permissions": [],
// "properties": [],
// "quotaBytesUsed": "my_quotaBytesUsed",
// "resourceKey": "my_resourceKey",
// "selfLink": "my_selfLink",
// "shareable": false,
// "shared": false,
// "sharedWithMeDate": "my_sharedWithMeDate",
// "sharingUser": {},
// "shortcutDetails": {},
// "spaces": [],
// "teamDriveId": "my_teamDriveId",
// "thumbnail": {},
// "thumbnailLink": "my_thumbnailLink",
// "thumbnailVersion": "my_thumbnailVersion",
// "title": "my_title",
// "trashedDate": "my_trashedDate",
// "trashingUser": {},
// "userPermission": {},
// "version": "my_version",
// "videoMediaMetadata": {},
// "webContentLink": "my_webContentLink",
// "webViewLink": "my_webViewLink",
// "writersCanShare": false
// }
}
main().catch(e => {
console.error(e);
throw e;
});
// Before running the sample:
// - Enable the API at:
// https://console.developers.google.com/apis/api/drive.googleapis.com
// - Login into gcloud by running:
// `$ gcloud auth application-default login`
// - Install the npm module by running:
// `$ npm install googleapis`
const {google} = require('googleapis');
const drive = google.drive('v3');
async function main() {
const auth = new google.auth.GoogleAuth({
// Scopes can be specified either as an array or as a single, space-delimited string.
scopes: ['https://www.googleapis.com/auth/drive'],
});
// Acquire an auth client, and bind it to all future calls
const authClient = await auth.getClient();
google.options({auth: authClient});
// Do the magic
const res = await drive.files.emptyTrash({
// Deprecated. If an item is not in a shared drive and its last parent is deleted but the item itself is not, the item will be placed under its owner's root.
enforceSingleParent: 'placeholder-value',
});
console.log(res.data);
}
main().catch(e => {
console.error(e);
throw e;
});
// Before running the sample:
// - Enable the API at:
// https://console.developers.google.com/apis/api/drive.googleapis.com
// - Login into gcloud by running:
// `$ gcloud auth application-default login`
// - Install the npm module by running:
// `$ npm install googleapis`
const {google} = require('googleapis');
const drive = google.drive('v2');
async function main() {
const auth = new google.auth.GoogleAuth({
// Scopes can be specified either as an array or as a single, space-delimited string.
scopes: [
'https://www.googleapis.com/auth/drive',
'https://www.googleapis.com/auth/drive.appdata',
'https://www.googleapis.com/auth/drive.file',
],
});
// Acquire an auth client, and bind it to all future calls
const authClient = await auth.getClient();
google.options({auth: authClient});
// Do the magic
const res = await drive.files.generateIds({
// Maximum number of IDs to return.
maxResults: 'placeholder-value',
// The space in which the IDs can be used to create new files. Supported values are 'drive' and 'appDataFolder'. (Default: 'drive')
space: 'placeholder-value',
// The type of items which the IDs can be used for. Supported values are 'files' and 'shortcuts'. Note that 'shortcuts' are only supported in the drive 'space'. (Default: 'files')
type: 'placeholder-value',
});
console.log(res.data);
// Example response
// {
// "ids": [],
// "kind": "my_kind",
// "space": "my_space"
// }
}
main().catch(e => {
console.error(e);
throw e;
});