1

I want to upload a file to multi folder google driver via API but only one file will be save, not each file for each folder. (1 file in serveral folder)

Example using by hand: Add the Same File to Multiple Folders in Google Drive without Copying

Could you please help me! Thank you!

1 Answer 1

3

In inserting a file in a folder, you need to specify the correct folder ID in the parents property of the file. Using Python:

folder_id = '0BwwA4oUTeiV1TGRPeTVjaWRDY1E'
file_metadata = {
  'name' : 'photo.jpg',
  'parents': [ folder_id ]
}
media = MediaFileUpload('files/photo.jpg',
                        mimetype='image/jpeg',
                        resumable=True)
file = drive_service.files().create(body=file_metadata,
                                    media_body=media,
                                    fields='id').execute()
print 'File ID: %s' % file.get('id')

As further mentioned in Files: insert, setting the parents[] property in the request body will put the file in all of the provided folders. If no folders are provided in parents[] field, the file will be placed in the default root folder.

Hope that helps!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.