Cómo crear un acceso directo a un archivo de Drive
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Los accesos directos son archivos que se vinculan a otros archivos o carpetas en Google Drive.
Los atajos tienen las siguientes características:
Es un tipo de MIME application/vnd.google-apps.shortcut
. Para obtener más información, consulta Tipos de MIME admitidos en Google Workspace y Google Drive.
La LCA de un acceso directo hereda la LCA del elemento superior. No se puede cambiar directamente la ACL del acceso directo.
Un targetId
que apunta al archivo o la carpeta de destino, también denominado "destino".
Un targetMimeType
que indica el tipo de MIME del destino. El campo targetMimeType
se usa para determinar el ícono de tipo que se mostrará. El tipo de MIME del destino se copia en el campo targetMimeType
cuando se crea el acceso directo.
Los campos targetId
y targetMimeType
forman parte del campo shortcutDetails
dentro del recurso archivo.
Un acceso directo solo puede tener un elemento superior. Si se requiere un archivo de acceso directo en otras ubicaciones de Drive, se puede copiar a las ubicaciones adicionales.
Cuando se borra el destino o cuando el usuario actual pierde el acceso a él, se rompe el acceso directo del usuario que apunta al destino.
El título de un acceso directo puede diferir del destino. Cuando se crea un acceso directo, el título del destino se usa como título del acceso directo. Después de la creación, el título del acceso directo y el título del destino se pueden cambiar de forma independiente. Si se cambia el nombre del destino, los accesos directos creados anteriormente conservan el título anterior.
El tipo de MIME de un acceso directo puede volverse obsoleto. Si bien es poco frecuente, el tipo de MIME de un archivo blob cambia cuando se sube una revisión de un tipo diferente, pero los accesos directos que apuntan al archivo actualizado conservan el tipo de MIME original. Por ejemplo, si subes un archivo JPG a Drive y, luego, subes una revisión en formato AVI, Drive identificará el cambio y actualizará la miniatura del archivo real. Sin embargo, el acceso directo sigue teniendo una miniatura JPG.
En la exportación de datos de la Cuenta de Google, también conocida como Google Takeout, los accesos directos se representan como archivos de favoritos de Netscape que contienen vínculos al destino.
Para obtener más información, consulta Cómo encontrar archivos y carpetas con los accesos directos de Google Drive.
Crear un acceso directo
Para crear un acceso directo, establece el tipo de MIME en application/vnd.google-apps.shortcut
, establece el targetId
en el archivo o la carpeta a los que debe vincularse el acceso directo y llama a files.create
para crear un acceso directo.
En los siguientes ejemplos, se muestra cómo crear un acceso directo con una biblioteca cliente:
Python
file_metadata = {
'name': 'FILE_NAME',
'mimeType': 'text/plain'
}
file = drive_service.files().create(body=file_metadata, fields='id').execute()
print('File ID: %s' % file.get('id'))
shortcut_metadata = {
'Name': 'SHORTCUT_NAME',
'mimeType': 'application/vnd.google-apps.shortcut',
'shortcutDetails': {
'targetId': file.get('id')
}
}
shortcut = drive_service.files().create(body=shortcut_metadata,
fields='id,shortcutDetails').execute()
print('File ID: %s, Shortcut Target ID: %s, Shortcut Target MIME type: %s' % (
shortcut.get('id'),
shortcut.get('shortcutDetails').get('targetId'),
shortcut.get('shortcutDetails').get('targetMimeType')))
Node.js
var fileMetadata = {
'name': 'FILE_NAME',
'mimeType': 'text/plain'
};
drive.files.create({
'resource': fileMetadata,
'fields': 'id'
}, function (err, file) {
if (err) {
// Handle error
console.error(err);
} else {
console.log('File Id: ' + file.id);
shortcutMetadata = {
'name': 'SHORTCUT_NAME',
'mimeType': 'application/vnd.google-apps.shortcut'
'shortcutDetails': {
'targetId': file.id
}
};
drive.files.create({
'resource': shortcutMetadata,
'fields': 'id,name,mimeType,shortcutDetails'
}, function(err, shortcut) {
if (err) {
// Handle error
console.error(err);
} else {
console.log('Shortcut Id: ' + shortcut.id +
', Name: ' + shortcut.name +
', target Id: ' + shortcut.shortcutDetails.targetId +
', target MIME type: ' + shortcut.shortcutDetails.targetMimeType);
}
}
}
});
Reemplaza lo siguiente:
- FILE_NAME: Es el nombre del archivo que requiere un acceso directo.
- SHORTCUT_NAME: Es el nombre de este acceso directo.
De forma predeterminada, el acceso directo se crea en Mi unidad del usuario actual y solo se crean accesos directos para los archivos o las carpetas a los que el usuario actual tiene acceso.
Cómo buscar un atajo
Para buscar un acceso directo, usa la cadena de consulta q
con files.list
para filtrar los accesos directos que se devolverán.
mimeType operator values
Donde:
- query_term es el término de búsqueda o el campo en el que se realizará la búsqueda. Para ver los términos de búsqueda que se pueden usar para filtrar unidades compartidas, consulta Términos de búsqueda.
- operator especifica la condición del término de búsqueda. Para ver qué operadores puedes usar con cada término de búsqueda, consulta Operadores de búsqueda.
- Los valores son los valores específicos que deseas usar para filtrar los resultados de la búsqueda.
Por ejemplo, la siguiente cadena de consulta filtra la búsqueda para mostrar todos los accesos directos a archivos de hojas de cálculo:
q: mimeType='application/vnd.google-apps.shortcut' AND shortcutDetails.targetMimeType='application/vnd.google-apps.spreadsheet'
Salvo que se indique lo contrario, el contenido de esta página está sujeto a la licencia Atribución 4.0 de Creative Commons, y los ejemplos de código están sujetos a la licencia Apache 2.0. Para obtener más información, consulta las políticas del sitio de Google Developers. Java es una marca registrada de Oracle o sus afiliados.
Última actualización: 2025-08-29 (UTC)
[null,null,["Última actualización: 2025-08-29 (UTC)"],[],[],null,["# Create a shortcut to a Drive file\n\n*Shortcuts* are files that link to other files or folders on Google Drive.\nShortcuts have these characteristics:\n\n- An `application/vnd.google-apps.shortcut` MIME type. For more information,\n see [Google Workspace \\& Google Drive supported MIME\n types](/workspace/drive/api/guides/mime-types).\n\n- The ACL for a shortcut inherits the ACL of the parent. The shortcut's ACL\n cannot be changed directly.\n\n- A `targetId` pointing to the target file or folder, also referred to as the\n \"target.\"\n\n- A `targetMimeType` indicating the MIME type for the target. The\n `targetMimeType` is used to determine the type icon to display. The target's\n MIME type is copied to the `targetMimeType` field when the shortcut is\n created.\n\n- The `targetId` and `targetMimeType` fields are part of the `shortcutDetails`\n field within the [file](/workspace/drive/api/reference/rest/v3/files) resource.\n\n- A shortcut can only have one parent. If a shortcut file is required in other\n Drive locations, the shortcut file can be copied to the\n additional locations.\n\n- When the target is deleted, or when the current user loses access to the\n target, the user's shortcut pointing to the target breaks.\n\n- The title of a shortcut can differ from the target. When a shortcut is\n created, the title of the target is used as the title of the shortcut. After\n creation, the shortcut's title and target's title can be changed\n independently. If the target's name is changed, previously created shortcuts\n retain the old title.\n\n- The MIME type of a shortcut can become stale. While rare, a blob file's MIME\n type changes when a revision of a different type is uploaded, but any\n shortcuts pointing to the updated file retain the original MIME type. For\n example, if you upload a JPG file to Drive, then upload an\n AVI revision, Drive identifies the change and updates the\n thumbnail for the actual file. However, the shortcut continues to have a JPG\n thumbnail.\n\n- In [Google Account Data\n Export](https://support.google.com/accounts/answer/3024190)\n also known as Google Takeout, shortcuts are represented as Netscape\n bookmark files containing links to the target.\n\nFor more information, see [Find files \\& folders with Google Drive\nshortcuts](https://support.google.com/drive/answer/9700156)\n.\n| **Important:** Previously, shortcuts were the term for files that pointed to content stored by an application. That type of \"shortcut\" was renamed to *third-party shortcut* . For further information, see [Create a shortcut file to\n| content stored by your app](/workspace/drive/api/guides/third-party-shortcuts).\n\nCreate a shortcut\n-----------------\n\nTo create a shortcut, set the MIME type to\n`application/vnd.google-apps.shortcut`, set the `targetId` to the file or folder\nthe shortcut should link to, and call [`files.create`](/workspace/drive/api/reference/rest/v3/files/create) to create a shortcut.\n| **Note:** If you're using V2 of the API, use [`files.insert`](/workspace/drive/api/v2/reference/files/insert).\n\nThe following examples show how to create a shortcut using a client library: \n\n### Python\n\n file_metadata = {\n 'name': '\u003cvar translate=\"no\"\u003eFILE_NAME\u003c/var\u003e',\n 'mimeType': 'text/plain'\n }\n file = drive_service.files().create(body=file_metadata, fields='id').execute()\n print('File ID: %s' % file.get('id'))\n shortcut_metadata = {\n 'Name': '\u003cvar translate=\"no\"\u003eSHORTCUT_NAME\u003c/var\u003e',\n 'mimeType': 'application/vnd.google-apps.shortcut',\n 'shortcutDetails': {\n 'targetId': file.get('id')\n }\n }\n shortcut = drive_service.files().create(body=shortcut_metadata,\n fields='id,shortcutDetails').execute()\n print('File ID: %s, Shortcut Target ID: %s, Shortcut Target MIME type: %s' % (\n shortcut.get('id'),\n shortcut.get('shortcutDetails').get('targetId'),\n shortcut.get('shortcutDetails').get('targetMimeType')))\n\n### Node.js\n\n var fileMetadata = {\n 'name': '\u003cvar translate=\"no\"\u003eFILE_NAME\u003c/var\u003e',\n 'mimeType': 'text/plain'\n };\n drive.files.create({\n 'resource': fileMetadata,\n 'fields': 'id'\n }, function (err, file) {\n if (err) {\n // Handle error\n console.error(err);\n } else {\n console.log('File Id: ' + file.id);\n shortcutMetadata = {\n 'name': '\u003cvar translate=\"no\"\u003eSHORTCUT_NAME\u003c/var\u003e',\n 'mimeType': 'application/vnd.google-apps.shortcut'\n 'shortcutDetails': {\n 'targetId': file.id\n }\n };\n drive.files.create({\n 'resource': shortcutMetadata,\n 'fields': 'id,name,mimeType,shortcutDetails'\n }, function(err, shortcut) {\n if (err) {\n // Handle error\n console.error(err);\n } else {\n console.log('Shortcut Id: ' + shortcut.id +\n ', Name: ' + shortcut.name +\n ', target Id: ' + shortcut.shortcutDetails.targetId +\n ', target MIME type: ' + shortcut.shortcutDetails.targetMimeType);\n }\n }\n }\n });\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eFILE_NAME\u003c/var\u003e: the file name requiring a shortcut.\n- \u003cvar translate=\"no\"\u003eSHORTCUT_NAME\u003c/var\u003e: the name for this shortcut.\n\nBy default, the shortcut is created on the current user's My\nDrive and shortcuts are only created for files or folders for\nwhich the current user has access.\n\nSearch for a shortcut\n---------------------\n\nTo search for a shortcut, use the query string `q` with\n[`files.list`](/workspace/drive/api/v3/reference/files/list) to filter the shortcuts to\nreturn.\n\n`mimeType `*operator values*\n\nWhere:\n\n- *query_term* is the query term or field to search upon. To view the query terms that can be used to filter shared drives, refer to [Search query\n terms](/workspace/drive/api/guides/ref-search-terms#file_properties).\n- *operator* specifies the condition for the query term. To view which operators you can use with each query term, refer to [Query operators](/workspace/drive/api/guides/ref-search-terms#operators).\n- *values* are the specific values you want to use to filter your search results.\n\nFor example, the following query string filters the search to return all\nshortcuts to spreadsheet files: \n\n q: mimeType='application/vnd.google-apps.shortcut' AND shortcutDetails.targetMimeType='application/vnd.google-apps.spreadsheet'"]]