Sha256: bff32e048b2ff3800075682cc0ef317bbf1bb030d674b2022097ecd5459a3784

Contents?: true

Size: 1.14 KB

Versions: 5

Compression:

Stored size: 1.14 KB

Contents

module ActionDispatch
  module Http

    class UploadedFile
      attr_accessor :original_filename

      attr_accessor :content_type

      attr_accessor :tempfile
      alias :to_io :tempfile

      attr_accessor :headers

      def initialize(hash)
        @tempfile          = hash[:tempfile]
        raise(ArgumentError, ":tempfile is required") unless @tempfile

        @original_filename = hash[:filename]
        if @original_filename
          begin
            @original_filename.encode!(Encoding::UTF_8)
          rescue EncodingError
            @original_filename.force_encoding(Encoding::UTF_8)
          end
        end
        @content_type      = hash[:type]
        @headers           = hash[:head]
      end

      def read(length=nil, buffer=nil)
        @tempfile.read(length, buffer)
      end

      def open
        @tempfile.open
      end

      def close(unlink_now=false)
        @tempfile.close(unlink_now)
      end

      def path
        @tempfile.path
      end

      def rewind
        @tempfile.rewind
      end

      def size
        @tempfile.size
      end

      def eof?
        @tempfile.eof?
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fastdfs-client-2.0.0 spec/upload.rb
fastdfs-client-1.4.4 spec/upload.rb
fastdfs-client-1.4.3 spec/upload.rb
fastdfs-client-1.4.1 spec/upload.rb
fastdfs-client-1.4.0 spec/upload.rb