Sha256: 1b40265bfeda4abff2c4cee3e7556f5106f9131bca29d62303b37c2d3766ffd5

Contents?: true

Size: 1.17 KB

Versions: 4

Compression:

Stored size: 1.17 KB

Contents

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

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

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

    # get List files from GroupDocs Storage
    file = GroupDocs::Storage::Folder.list!("", {}, {:client_id => settings.client_id, :private_key => settings.private_key})
    file_name = ''

    # choose the desired file
    file.map do |element|
      if element.name == settings.name
          file_name = element
      end
    end

    # delete file from GroupDocs Storage
    file_name.delete!({:client_id => settings.client_id, :private_key => settings.private_key})

    message = 'File was deleted from GroupDocs Storage'

  rescue Exception => e
    err = e.message
  end

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

Version data entries

4 entries across 4 versions & 1 rubygems

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