Third-party shortcuts are files that link to files on other, external, storage systems.
To create a third-party shortcut, use the
files.create
method
of the API and make sure you set the MIME type
application/vnd.google-apps.drive-sdk
. Do not upload any content when
creating the file.
Java
File fileMetadata = new File();
fileMetadata.setTitle("Project plan");
fileMetadata.setMimeType("application/vnd.google-apps.drive-sdk");
File file = driveService.files().insert(fileMetadata)
.setFields("id")
.execute();
System.out.println("File ID: " + file.getId());
Python
file_metadata = {
'title': 'Project plan',
'mimeType': 'application/vnd.google-apps.drive-sdk'
}
file = drive_service.files().insert(body=file_metadata,
fields='id').execute()
print 'File ID: %s' % file.get('id')
PHP
$fileMetadata = new Google_Service_Drive_DriveFile(array(
'title' => 'Project plan',
'mimeType' => 'application/vnd.google-apps.drive-sdk'));
$file = $driveService->files->insert($fileMetadata, array(
'fields' => 'id'));
printf("File ID: %s\n", $file->id);
.NET
var fileMetadata = new File()
{
Title = "Project plan",
MimeType = "application/vnd.google-apps.drive-sdk"
};
var request = driveService.Files.Insert(fileMetadata);
request.Fields = "id";
var file = request.Execute();
Console.WriteLine("File ID: " + file.Id);
Ruby
file_metadata = {
title: 'Project plan',
mime_type: 'application/vnd.google-apps.drive-sdk'
}
file = drive_service.insert_file(file_metadata, fields: 'id')
puts "File Id: #{file.id}"
Node.js
var fileMetadata = {
'title': 'Project plan',
'mimeType': 'application/vnd.google-apps.drive-sdk'
};
drive.files.insert({
resource: fileMetadata,
fields: 'id'
}, function (err, file) {
if (err) {
// Handle error
console.error(err);
} else {
console.log('File Id:', file.id);
}
});
Adding custom thumbnails and indexable text
To increase the discoverability of files associated with third-party shortcuts, you can upload both thumbnail images and indexable text when inserting or modifying the file metadata. For more information, see Manage File Metadata.