@@ -46,12 +46,12 @@ class File < Part
4646 # @option opts [#to_s] :filename
4747 # When `path_or_io` is a String, Pathname or File, defaults to basename.
4848 # When `path_or_io` is a IO, defaults to `"stream-{object_id}"`
49- def initialize ( path_or_io , opts = { } ) # rubocop:disable Lint/MissingSuper
49+ def initialize ( path_or_io , opts = nil ) # rubocop:disable Lint/MissingSuper
5050 opts = FormData . ensure_hash ( opts )
5151
5252 if opts . key? :mime_type
5353 warn "[DEPRECATED] :mime_type option deprecated, use :content_type"
54- opts [ :content_type ] = opts [ :mime_type ]
54+ opts [ :content_type ] = opts . fetch ( :mime_type )
5555 end
5656
5757 @io = make_io ( path_or_io )
@@ -68,8 +68,8 @@ def initialize(path_or_io, opts = {}) # rubocop:disable Lint/MissingSuper
6868 # @return [IO]
6969 def make_io ( path_or_io )
7070 if path_or_io . is_a? ( String )
71- ::File . open ( path_or_io , binmode : true )
72- elsif defined? ( Pathname ) && path_or_io . is_a? ( Pathname )
71+ ::File . new ( path_or_io , binmode : true )
72+ elsif path_or_io . is_a? ( Pathname )
7373 path_or_io . open ( binmode : true )
7474 else
7575 path_or_io
@@ -83,7 +83,7 @@ def make_io(path_or_io)
8383 # @return [String]
8484 def filename_for ( io )
8585 if io . respond_to? ( :path )
86- ::File . basename io . path
86+ io . path . split ( ::File :: SEPARATOR ) . last
8787 else
8888 "stream-#{ io . object_id } "
8989 end
0 commit comments