我正在使用Google云端硬盘开发应用.我希望用户能够通过链接共享文件,权限设置anyone,并withLink作为中描述谷歌开发者文档.
但是,我无法弄清楚要分享的链接.当我在Google云端硬盘浏览器界面中共享文件时,我会看到Link to share以下格式:
https://docs.google.com/presentation/d/[...]/edit?usp=sharing
此格式的链接不是文件资源对象的一部分,也不是从设置权限的http调用返回的.我希望有人可以向我解释如何通过REST API获取此链接?
Cla*_*ino 17
您可以使用alternateLink文件资源中的属性来获取可以共享的链接,以便在相关的Google编辑器或查看器中打开文件:
https://developers.google.com/drive/v2/reference/files
rzy*_*mek 12
要使用Google Drive API实际启用链接共享:
drive.permissions.create({
fileId: '......',
requestBody: {
role: 'reader',
type: 'anyone',
}
});
Run Code Online (Sandbox Code Playgroud)
webLinkView使用以下方法获取值:
const webViewLink = await drive.files.get({
fileId: file.id,
fields: 'webViewLink'
}).then(response =>
response.data.webViewLink
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
25966 次 |
| 最近记录: |