无法更新 google 驱动器 v3 api 中文件的缩略图 link
Unable to update Thumbnail link of a file in google drive v3 api
我正在使用 curl 工具中的 google drive-v3 API 进行实验。在这里,我创建了新的空文件(只有文件名),下面是 API.
curl --request POST https://www.googleapis.com/drive/v3/files --header 'Authorization: Bearer [ACCESS-TOKEN]' --header 'Accept: application/json' --header 'Content-Type: application/json' --data '{'\''name'\'':'\''New-EmptyFile.jpg'\'','\''parents'\'':['\''1_m7AipvwhKayhy6awYETqJYnp51vU_I1'\''],'\''mimeType'\'':'\''image/jpeg'\''}' --compressed
创建的新空图像文件没有图像数据和缩略图。
{
"id": "170zfkmx03z0NzGOwp0f0loGj1Q4rAJt7",
"name": "New-EmptyFile.jpg",
"createdTime": "2019-04-05T20:19:02.077Z"
}
因此,我尝试使用 google 驱动器中已存在的文件之一的缩略图 link 更新图像文件的缩略图,但出现以下错误。
缩略图link:
https://lh3.googleusercontent.com/8Xb7kzH-cggIF-NfH5qjiHc_nea0ZhlYW_tcsfX6-W37UZIhiBIljvyRs4c7MGC_-h4K5fB-hZg=s220
更新缩略图的 Curl 命令:
curl -# --request PATCH https://www.googleapis.com/drive/v3/files/170zfkmx03z0NzGOwp0f0loGj1Q4rAJt7 --header 'Authorization: Bearer ya29.GlvjBgWHr1i1uM_yJCBkw7du50QbCWbJ0jb0kVZEfRudisakYW2hs681cYbhdxrTpFuhLPdjzPilyccoG_TiKTG_YmeLOv4mu2BAuNf3ZCxXpOmexLSjdm657VZK' --header 'Accept: application/json' --header 'Content-Type: application/json' --data '{"thumbnailLink":"https://lh3.googleusercontent.com/8Xb7kzH-cggIF-NfH5qjiHc_nea0ZhlYW_tcsfX6-W37UZIhiBIljvyRs4c7MGC_-h4K5fB-hZg=s220"}' --compressed
错误响应:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "fieldNotWritable",
"message": "The resource body includes fields which are not directly writable."
}
],
"code": 403,
"message": "The resource body includes fields which are not directly writable."
}
}
如何解决和更新缩略图?
If Drive can generate a thumbnail from the file, then it will use the generated one and ignore any you may have uploaded. If it can't generate a thumbnail, it will always use yours if you provided one.
因此,很遗憾,无法修改图像文件的缩略图。
- 虽然我尝试修改图片文件的缩略图,但我确认在目前阶段,还不能实现。
- 例如zip文件,可以修改缩略图。
参考:
我正在使用 curl 工具中的 google drive-v3 API 进行实验。在这里,我创建了新的空文件(只有文件名),下面是 API.
curl --request POST https://www.googleapis.com/drive/v3/files --header 'Authorization: Bearer [ACCESS-TOKEN]' --header 'Accept: application/json' --header 'Content-Type: application/json' --data '{'\''name'\'':'\''New-EmptyFile.jpg'\'','\''parents'\'':['\''1_m7AipvwhKayhy6awYETqJYnp51vU_I1'\''],'\''mimeType'\'':'\''image/jpeg'\''}' --compressed
创建的新空图像文件没有图像数据和缩略图。
{
"id": "170zfkmx03z0NzGOwp0f0loGj1Q4rAJt7",
"name": "New-EmptyFile.jpg",
"createdTime": "2019-04-05T20:19:02.077Z"
}
因此,我尝试使用 google 驱动器中已存在的文件之一的缩略图 link 更新图像文件的缩略图,但出现以下错误。
缩略图link:
https://lh3.googleusercontent.com/8Xb7kzH-cggIF-NfH5qjiHc_nea0ZhlYW_tcsfX6-W37UZIhiBIljvyRs4c7MGC_-h4K5fB-hZg=s220
更新缩略图的 Curl 命令:
curl -# --request PATCH https://www.googleapis.com/drive/v3/files/170zfkmx03z0NzGOwp0f0loGj1Q4rAJt7 --header 'Authorization: Bearer ya29.GlvjBgWHr1i1uM_yJCBkw7du50QbCWbJ0jb0kVZEfRudisakYW2hs681cYbhdxrTpFuhLPdjzPilyccoG_TiKTG_YmeLOv4mu2BAuNf3ZCxXpOmexLSjdm657VZK' --header 'Accept: application/json' --header 'Content-Type: application/json' --data '{"thumbnailLink":"https://lh3.googleusercontent.com/8Xb7kzH-cggIF-NfH5qjiHc_nea0ZhlYW_tcsfX6-W37UZIhiBIljvyRs4c7MGC_-h4K5fB-hZg=s220"}' --compressed
错误响应:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "fieldNotWritable",
"message": "The resource body includes fields which are not directly writable."
}
],
"code": 403,
"message": "The resource body includes fields which are not directly writable."
}
}
如何解决和更新缩略图?
If Drive can generate a thumbnail from the file, then it will use the generated one and ignore any you may have uploaded. If it can't generate a thumbnail, it will always use yours if you provided one.
因此,很遗憾,无法修改图像文件的缩略图。
- 虽然我尝试修改图片文件的缩略图,但我确认在目前阶段,还不能实现。
- 例如zip文件,可以修改缩略图。