I want to upload to the folder specified by GoogleDrive using Google_drive gem

Asked 2 years ago, Updated 2 years ago, 157 views

Conclusion

I want to know how to upload CSV files to the folder specified in GoogleDrive

What do you want to do

I am thinking of uploading CSV created daily using Google-drive-ruby to GoogleDrive's designated folder on rails batches.
(API is here http://www.rubydoc.info/gems/google_drive/2.1.2/GoogleDrive/Session)

Current state

Gemfile

gem 'google_drive', '2.1.2'

Batch Files

require "google_drive"
require "csv"
(omitted)
defaultupload_csv
session.upload_from_file(
my_csv,
"# {Date.today.strftime('my_csv_%Y%m%d%H%M%S')}",
convert —true
)
end

I can upload CSV itself with the above code, but I can't select the folder to upload to, so I just throw it into the top screen of GoogleDrive.
I would like to upload CSV to a folder dedicated to the batch, but the API does not mention how to do so.
On the contrary, if you look at the API source, you will see the following TODO:

#TODO:Add a feature to upload to a folder.

What questions would you like to ask

Is it not possible to specify the folder to be uploaded according to the current specification?
If you can't, please let me know if you know any other good ways.
(I don't want to use Google_drive version down as much as possible.)

Supplementary

This is my first time to ask a programming question online.
If there is anything that can be improved by asking questions, I would appreciate it if you could point that out.
Thank you for your cooperation.

ruby google-drive-sdk

2022-09-29 21:19

1 Answers

#TODO:Add a feature to upload to a folder.

Also, it seems that the upload function to a specific folder has not yet been implemented, so if you only need to transfer, how about calling an external program such as rclone using system as follows?

system("rclone${local_path}#{remote_path}")


2022-09-29 21:19

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.