0

I can upload files in root folder of Google-drive using Google-drive APIs. But I cannot upload files to non-root folders. Is it possible to upload a file in non-root folders using APIs?and DO we have any other APIs for uploading a file in non-root folders.

I am using "https://www.googleapis.com/upload/drive/v3/files" Url and I am trying to append file-Id to this Url, but I failed to upload the file to a sub-folder.

pinoyyid
  • 21,499
  • 14
  • 64
  • 115
RakeshSharma227
  • 361
  • 1
  • 5
  • 15

1 Answers1

3

I suggest start by reading this post How do I search sub-folders and sub-sub-folders in Google Drive?. Even though the question is about searching, you will find the answer will help you to understand Drive folders. Once you realise that a Folder is really just a label, the answer will be obvious.

In simple terms, your file metadata must contain an array called "parents" (https://developers.google.com/drive/v3/reference/files#resource-representations). Simply populate that array with the file IDs of the folders you want the new file to be created in.

Community
  • 1
  • 1
pinoyyid
  • 21,499
  • 14
  • 64
  • 115