Method: DocumentExporter::Gdoc::Base#export_to

Defined in:
lib/document_exporter/gdoc/base.rb

#export_to(folder_id, file_id: nil) ⇒ Object

Parameters:

  • folder_id

    String ID of folder export file to

  • file_id (defaults to: nil)

    String ID of existing file



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/document_exporter/gdoc/base.rb', line 70

def export_to(folder_id, file_id: nil)
   = Google::Apis::DriveV3::File.new(
    name: document.base_filename(with_version: false),
    mime_type: 'application/vnd.google-apps.document',
    parents: [folder_id]
  )

  params = {
    content_type: 'text/html',
    upload_source: StringIO.new(content)
  }.merge(GOOGLE_API_UPLOAD_OPTIONS)

  @id = if file_id.present?
          drive_service.service.update_file(file_id, , params)
        else
          drive_service.service.create_file(, params)
        end.id

  post_processing

  self
end