Google 驱动器上传图像 - 数据未返回 webContentLink - 直接永久 link
Google Drive Upload Image - Data not returning webContentLink - Direct permenant link
我正在像这样成功地将图像上传到 API:
https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart
Authorization: 'Bearer ' + token,
'Content-Type': 'multipart/form-data; boundary="' + boundary + '"'
--data: multipartRequestBody
其中 multipartRequestBody
是:
{
name: 'screenshot.png',
mimeType: 'image/png',
// parents: ['0B5IwavgVGMN9ekR2dEhuaUxkZTA'] // set this to the id of a the folder you want to upload it into
};
我可以向我的 mulitpartRequestBody
提供一些密钥,告诉 GDrive 将此文件作为公开共享文件上传并 return webContentLink
吗?我可以在 <img src="...">
的 src
中使用哪个,而对观看带宽没有限制?
我已经尝试设置 writersCanShare: true
,但它仍然不会 return 和 webContentLink
。我也试过添加 type: 'anyone', role: 'reader'
但这也没有用。
基本上我正在尝试做 https://drive.google.com/uc?export=view&id={fileId}
所做的事情,但是在 insert
调用 API.
中
谢谢
对您的所有要求的简短回答是否定的。
Drive 并非设计为免费 public 托管服务,而是 sharing/viewing/editing 人与人之间的内容。如果您真的想以需要 "no restrictions on view bandwidth".
的方式使用它,您将 运行 了解带宽限制、滥用检测等。
另一个主要部分是您必须根据 files.insert
调用中返回的 ID 执行 files.get
请求 - 您将无法在单个 API 仅调用插入。
使用与云端硬盘类似的Google Cloud Storage which has a REST/JSON API,您会得到更好的服务。
我正在像这样成功地将图像上传到 API:
https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart
Authorization: 'Bearer ' + token,
'Content-Type': 'multipart/form-data; boundary="' + boundary + '"'
--data: multipartRequestBody
其中 multipartRequestBody
是:
{
name: 'screenshot.png',
mimeType: 'image/png',
// parents: ['0B5IwavgVGMN9ekR2dEhuaUxkZTA'] // set this to the id of a the folder you want to upload it into
};
我可以向我的 mulitpartRequestBody
提供一些密钥,告诉 GDrive 将此文件作为公开共享文件上传并 return webContentLink
吗?我可以在 <img src="...">
的 src
中使用哪个,而对观看带宽没有限制?
我已经尝试设置 writersCanShare: true
,但它仍然不会 return 和 webContentLink
。我也试过添加 type: 'anyone', role: 'reader'
但这也没有用。
基本上我正在尝试做 https://drive.google.com/uc?export=view&id={fileId}
所做的事情,但是在 insert
调用 API.
谢谢
对您的所有要求的简短回答是否定的。
Drive 并非设计为免费 public 托管服务,而是 sharing/viewing/editing 人与人之间的内容。如果您真的想以需要 "no restrictions on view bandwidth".
的方式使用它,您将 运行 了解带宽限制、滥用检测等。另一个主要部分是您必须根据 files.insert
调用中返回的 ID 执行 files.get
请求 - 您将无法在单个 API 仅调用插入。
使用与云端硬盘类似的Google Cloud Storage which has a REST/JSON API,您会得到更好的服务。