lib/cloudinary/uploader.rb in cloudinary-1.27.0 vs lib/cloudinary/uploader.rb in cloudinary-1.28.0

- old
+ new

@@ -38,10 +38,11 @@ :eager => Cloudinary::Utils.build_eager(options[:eager]), :eager_async => Cloudinary::Utils.as_safe_bool(options[:eager_async]), :eager_notification_url => options[:eager_notification_url], :exif => Cloudinary::Utils.as_safe_bool(options[:exif]), :eval => options[:eval], + :on_success => options[:on_success], :face_coordinates => Cloudinary::Utils.encode_double_array(options[:face_coordinates]), :faces => Cloudinary::Utils.as_safe_bool(options[:faces]), :folder => options[:folder], :format => options[:format], :filename_override => options[:filename_override], @@ -85,20 +86,11 @@ end def self.upload(file, options={}) call_api("upload", options) do params = build_upload_params(options) - if file.is_a?(Pathname) - params[:file] = File.open(file, "rb") - elsif file.is_a?(StringIO) - file.rewind - params[:file] = Cloudinary::Blob.new(file.read, options) - elsif file.respond_to?(:read) || Cloudinary::Utils.is_remote?(file) - params[:file] = file - else - params[:file] = File.open(file, "rb") - end + params[:file] = Cloudinary::Utils.handle_file_param(file, options) [params, [:file]] end end # Upload large files. Note that public_id should include an extension for best results. @@ -151,14 +143,10 @@ # Upload large files. Note that public_id should include an extension for best results. def self.upload_large_part(file, options={}) options[:resource_type] ||= :raw call_api("upload", options) do params = build_upload_params(options) - if file.is_a?(Pathname) || !file.respond_to?(:read) - params[:file] = File.open(file, "rb") - else - params[:file] = file - end + params[:file] = Cloudinary::Utils.handle_file_param(file, options) [params, [:file]] end end def self.destroy(public_id, options={})