1

I use gem google drive v.2.1.2, and I searched api from here.

According to this api, I can upload files by following code.

session.upload_from_file("/path/to/hoge.txt")

In this api, no way to specify a folder to which I can upload my files.

If you know the way to specify a foloder, please tell me.

pinoyyid
  • 21,499
  • 14
  • 64
  • 115
shu15
  • 11
  • 2

1 Answers1

1

Here is the code from the Drive documentation that tells you on how to insert a file in a particular folder, specifying the correct ID in the parents property of the file.

folder_id = '0BwwA4oUTeiV1TGRPeTVjaWRDY1E'
file_metadata = {
name: 'photo.jpg',
parents: [folder_id]
}
file = drive_service.create_file(file_metadata,
fields: 'id',
upload_source: 'files/photo.jpg',
content_type: 'image/jpeg')
puts "File Id: #{file.id}"

For more information, check this SO question if it can help you.

Community
  • 1
  • 1
KENdi
  • 7,576
  • 2
  • 16
  • 31