0
votes

I am trying to upload a image with metadata inside a folder on google-drive but I am not able to do so.I came across this link https://developers.google.com/drive/folder which shows a way to upload image to a folder but example on that page is not complete.I am able to upload image at root of google-drive using uploadtype=multipart as shown here https://developers.google.com/drive/manage-uploads .So can anybody tell me how could I upload image with metadata inside a folder in same way as uploadtype=multipart.I tried inserting id of folder and kind:drive#fileLink but it's not working. Can anybody tell me how could i achieve my aim to upload image inside a folder.

1

1 Answers

1
votes

You want to use Files.insert() to upload a file with metadata. The link has full working code in various languages you want to start with.

For your specific case where you want to upload a file to a folder, you want to specify them in your request body. Here is a sample request example.

POST https://www.googleapis.com/drive/v2/files

Content-Type:  application/json
Authorization:  Bearer {{ AUTH_CODE }}

{
 "title": "image.jpg",
 "mimeType": "image/jpeg",
 "parents": [
  {
   "id": "root"
  }
 ]
}