I was doing an experiment with google drive-v3 API from the curl tool. Here I have created the new empty file (with filename alone) with below 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
The new empty image file gets created without image data and thumbnail.
{
"id": "170zfkmx03z0NzGOwp0f0loGj1Q4rAJt7",
"name": "New-EmptyFile.jpg",
"createdTime": "2019-04-05T20:19:02.077Z"
}
So, I have tried to update the thumbnail for the image file using the thumbnail link of one of a file that already exists in my google drive but I was getting the below error.
Thumbnail link:
https://lh3.googleusercontent.com/8Xb7kzH-cggIF-NfH5qjiHc_nea0ZhlYW_tcsfX6-W37UZIhiBIljvyRs4c7MGC_-h4K5fB-hZg=s220
Curl command to update thumbnail:
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 Response:
{
"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."
}
}
How to resolve and update the thumbnail ?
The official document says as follows.
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.
By this, unfortunately, the thumbnail of image file cannot be modified.