Sha256: dc978a0d0e926d16055152a18f9d5b5f0736e05929ed7b38c2edd903eec8a1bc

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

require 'cgi'
require 'faraday'

module Smartsheet
  module API
    # Specification for a file attachment by path, target filename, and MIME content type
    class PathFileSpec
      attr_reader :upload_io, :filename, :content_type, :file_length

      def initialize(path, filename, content_type)
        @file_length = File.size(path)
        @filename = filename.nil? ? File.basename(path) : filename
        @upload_io = Faraday::UploadIO.new(path, content_type, CGI::escape(@filename))
        @content_type = content_type
      end
    end

    # Specification for a file attachment by {::File}, target filename, file length, and MIME
    # content type
    class ObjectFileSpec
      attr_reader :upload_io, :filename, :content_type, :file_length

      def initialize(file, filename, file_length, content_type)
        @file_length = file_length
        @filename = filename
        @upload_io = Faraday::UploadIO.new(file, content_type, CGI::escape(filename))
        @content_type = content_type
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
smartsheet-1.0.0 lib/smartsheet/api/file_spec.rb