Method: GoogleDrive::Session#upload_from_string

Defined in:
lib/google_drive/session.rb

#upload_from_string(content, title = 'Untitled', params = {}) ⇒ Object

Uploads a file with the given title and content. Returns a GoogleSpreadsheet::File object.

e.g.

# Uploads and converts to a Google Docs document:
session.upload_from_string(
    "Hello world.", "Hello", :content_type => "text/plain")

# Uploads without conversion:
session.upload_from_string(
    "Hello world.", "Hello", :content_type => "text/plain", :convert => false)

# Uploads and converts to a Google Spreadsheet:
session.upload_from_string("hoge\tfoo\n", "Hoge", :content_type => "text/tab-separated-values")
session.upload_from_string("hoge,foo\n", "Hoge", :content_type => "text/tsv")


386
387
388
# File 'lib/google_drive/session.rb', line 386

def upload_from_string(content, title = 'Untitled', params = {})
  upload_from_source(StringIO.new(content), title, params)
end