Class: Lt::Lcms::Lesson::Uploader::Gdoc
- Inherits:
-
Object
- Object
- Lt::Lcms::Lesson::Uploader::Gdoc
- Defined in:
- lib/lt/lcms/lesson/uploader/gdoc.rb
Instance Method Summary collapse
-
#initialize(credentials) ⇒ Gdoc
constructor
A new instance of Gdoc.
- #upload(name, content, content_type, parent_folder_id = nil) ⇒ Object
Constructor Details
#initialize(credentials) ⇒ Gdoc
Returns a new instance of Gdoc.
8 9 10 |
# File 'lib/lt/lcms/lesson/uploader/gdoc.rb', line 8 def initialize(credentials) @credentials = credentials end |
Instance Method Details
#upload(name, content, content_type, parent_folder_id = nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/lt/lcms/lesson/uploader/gdoc.rb', line 12 def upload(name, content, content_type, parent_folder_id = nil) = { name: name, mime_type: Lt::Google::Api::Drive::MIME_FILE } [:parents] = Array.wrap(parent_folder_id) unless parent_folder_id.nil? file = service.create_file( , fields: 'id', upload_source: StringIO.new(content), content_type: content_type, supports_all_drives: true ) file.id end |