shrinerb / shrine

File Attachment toolkit for Ruby applications
https://shrinerb.com
MIT License
3.18k stars 275 forks source link

Shrine 3.5.0 does not support Rack 3 (undefined method `map' for #Rack::Files::Iterator) #672

Closed vrodic closed 6 months ago

vrodic commented 8 months ago

When using a Rails 7 application with Rack 3 and Shrine 3.5.0 we are getting a

NoMethodError

undefined method `map' for #<Rack::Files::Iterator:0x0000786dd78a7560 @path="/tmp/image_processing20240221-90664-78pq2t.jpg", @ranges=[0..1343], @options={:mime_type=>"image/jpeg", :size=>1344}>

shrine (3.5.0) lib/shrine/plugins/derivation_endpoint.rb:368:in `call`

This is the offending line:

headers["Content-Length"] ||= body.map(&:bytesize).inject(0, :+).to_s

I see there are already PRs to fix this:

https://github.com/shrinerb/shrine/pull/661 https://github.com/shrinerb/shrine/pull/660

davidalejandroaguilar commented 7 months ago

https://github.com/shrinerb/shrine/pull/660 and https://github.com/shrinerb/shrine/pull/661 fixes this.

The former fixes the underlying header capitalization change issue introduced on Rack > 2, while the latter fixes Shrine's fallback that should've guarded against this.

tomasc commented 7 months ago

see #682

janko commented 6 months ago

Should be fixed by https://github.com/shrinerb/shrine/pull/682.