Sha256: 256e8d13136b72b21564d80b8e945d73450156a713e0530dbfa287f7b0c2f7b6

Contents?: true

Size: 591 Bytes

Versions: 2

Compression:

Stored size: 591 Bytes

Contents

module Acme
  class UploadFile < Grape::API
    format :json

    desc 'Upload an image.'
    post 'avatar' do
      {
        filename: params[:image_file][:filename],
        size: params[:image_file][:tempfile].size
      }
    end

    desc 'Upload and download a file of any format.'
    post 'download' do
      filename = params[:file][:filename]
      content_type MIME::Types.type_for(filename)[0].to_s
      env['api.format'] = :binary
      header 'Content-Disposition', "attachment; filename*=UTF-8''#{URI.escape(filename)}"
      params[:file][:tempfile].read
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vitals-0.4.0 integration/multiverse/grape-on-rack/api/upload_file.rb
vitals-0.3.0 integration/multiverse/grape-on-rack/api/upload_file.rb