Sha256: 91430ec8afd1490d5a0c5503466444571bcf339bfc0b80160a35c1a2333ac7ae

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

# GET request
get '/sample24' do
  haml :sample24
end

# POST request
post '/sample24' do
  # set variables
  set :client_id, params[:client_id]
  set :private_key, params[:private_key]
  set :url, params[:url]

  begin
    # check required variables
    raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty? or settings.url.nil?

    # upload web file
    file = GroupDocs::Storage::File.upload_web!(settings.url, {:client_id => settings.client_id, :private_key => settings.private_key})

    # construct result messages
    message = "<p>File was uploaded to GroupDocs. Here you can see your <strong> file in the GroupDocs Embedded Viewer.</p>"
    iframe = "<iframe src='https://apps.groupdocs.com/document-viewer/Embed/#{file.guid}' frameborder='0' width='720' height='600'></iframe>"

  rescue Exception => e
    err = e.message
  end

  # set variables for template
  haml :sample24, :locals => {:userId => settings.client_id, :privateKey => settings.private_key, :iframe => iframe, :message => message, :err => err}
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
groupdocs-1.5.7 examples/api-samples/samples/sample24.rb
groupdocs-1.5.6 examples/api-samples/samples/sample24.rb
groupdocs-1.5.5 examples/api-samples/samples/sample24.rb
groupdocs-1.5.4 examples/api-samples/samples/sample24.rb