Skip to content

Commit

Permalink
Remove deprecated File (#37)
Browse files Browse the repository at this point in the history
Since `Faraday::Multipart::FilePart` is defined in
[faraday-multipart](https://rubygems.org/gems/faraday-multipart), which
is now always included, the fallback to `File` can be removed.

This is especially important, because `File.new` never allowed setting
the content type anyway.

```ruby
spec.add_dependency "faraday", ">= 2", "<= 3"
spec.add_dependency "faraday-multipart", "~> 1.0"
spec.add_dependency "faraday-retry", "~> 2.2"
```
  • Loading branch information
otherguy authored Jul 25, 2024
1 parent b19baae commit ddf7f43
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions lib/remove_bg/upload.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def self.for_file(file_path)
raise RemoveBg::FileMissingError.new(file_path) unless File.exist?(file_path)

content_type = determine_content_type(file_path)
FARADAY_FILE.new(file_path, content_type)
Faraday::Multipart::FilePart.new(file_path, content_type)
end

def self.determine_content_type(file_path)
Expand All @@ -23,13 +23,5 @@ def self.determine_content_type(file_path)
end

private_class_method :determine_content_type

FARADAY_FILE = if defined?(Faraday::Multipart::FilePart)
Faraday::Multipart::FilePart
else
File
end.freeze

private_constant :FARADAY_FILE
end
end

0 comments on commit ddf7f43

Please sign in to comment.