shrine 3.7.0 → 3.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/doc/plugins/derivation_endpoint.md +13 -0
- data/doc/plugins/rack_response.md +9 -0
- data/doc/release_notes/3.7.1.md +13 -0
- data/lib/shrine/plugins/_persistence.rb +1 -1
- data/lib/shrine/plugins/data_uri.rb +1 -1
- data/lib/shrine/plugins/derivation_endpoint.rb +6 -4
- data/lib/shrine/plugins/metadata_attributes.rb +1 -1
- data/lib/shrine/plugins/rack_response.rb +2 -2
- data/lib/shrine/plugins/remote_url.rb +1 -1
- data/lib/shrine/plugins/validation_helpers.rb +1 -1
- data/lib/shrine/version.rb +1 -1
- data/shrine.gemspec +2 -2
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 29a02d25cd1180c4f0170434edd185b3b1ab0bd2be060fa53e58fcd32c50d4ae
|
|
4
|
+
data.tar.gz: 56e50d961ef88e0d3cae4d295b6996c52cd2021b923d9b453f401f10b04021b3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cb06f261af63f09ba767556d65f8b99e5204c1162ce7d8e28e5355148539a02c486fa088819884cf38dee4bf0683e8167b6582c4a028271a5145bd8661f64765
|
|
7
|
+
data.tar.gz: ec5cd4f04fe90ada87cd594bf78e61c2de9fcbebe8d51cb9e49b0bec566614be5ea5826382a8f25608888c84a951f25ad80442a6af2d641a37bae0e8fe184d7e
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
## 3.7.1 (2026-06-03)
|
|
2
|
+
|
|
3
|
+
* Update method signatures of some plugins to work around a Bootsnap bug causing a `wrong number of arguments` error.
|
|
4
|
+
|
|
1
5
|
## 3.7.0 (2026-05-27)
|
|
2
6
|
|
|
7
|
+
* `rack_response` - Add `:etag` option for setting a custom `ETag` header (@janko)
|
|
8
|
+
|
|
3
9
|
* `download_endpoint` - Add support for expiring URLs (@davidwessman)
|
|
4
10
|
|
|
5
11
|
* `s3` - Use `TransferManager` where available instead of deprecated `upload_steam` (@danieldevlewis)
|
|
@@ -309,6 +309,19 @@ uploaded_file.derivation_url(:thumbnail, prefix: "transformations/image")
|
|
|
309
309
|
#=> ".../transformations/image/thumbnail/eyJpZCI6ImZvbyIsInN?signature=..."
|
|
310
310
|
```
|
|
311
311
|
|
|
312
|
+
## Format
|
|
313
|
+
|
|
314
|
+
Some HTTP clients and CDNs use the URL path extension to determine the content
|
|
315
|
+
type of the response. You can append a file extension to the derivation URL
|
|
316
|
+
path with the `:format` option:
|
|
317
|
+
|
|
318
|
+
```rb
|
|
319
|
+
uploaded_file.derivation_url(:thumbnail, format: "jpg")
|
|
320
|
+
#=> ".../thumbnail/eyJpZCI6ImZvbyIsInN.jpg?signature=..."
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
The extension is included in the URL signature, so it cannot be tampered with.
|
|
324
|
+
|
|
312
325
|
## Expiration
|
|
313
326
|
|
|
314
327
|
By default derivation URLs are valid indefinitely. If you want URLs to expire
|
|
@@ -95,6 +95,15 @@ headers["Content-Range"] #=> "bytes 100-200/1000"
|
|
|
95
95
|
body # partial content
|
|
96
96
|
```
|
|
97
97
|
|
|
98
|
+
## ETag
|
|
99
|
+
|
|
100
|
+
A custom ETag value can be provided via the `:etag` option:
|
|
101
|
+
|
|
102
|
+
```rb
|
|
103
|
+
response = uploaded_file.to_rack_response(etag: "my-custom-etag")
|
|
104
|
+
response[1]["ETag"] #=> "my-custom-etag"
|
|
105
|
+
```
|
|
106
|
+
|
|
98
107
|
## Download options
|
|
99
108
|
|
|
100
109
|
The `#to_rack_response` method will automatically open the `UploadedFile` if it
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Shrine 3.7.1
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
## Bug fixes
|
|
6
|
+
|
|
7
|
+
* When initializing Shrine with the `activerecord` plugin, under Bootsnap 1.24.5 and Ruby 3.4.5 this would raise an error:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
ArgumentError: wrong number of arguments (given 2, expected 1; required keyword: plugin)
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The seems to be triggered by a special combination of method signatures, where keyword arguments get converted into positional arguments under Bootsnap. To work around this issue, method signatures of some plugin methods have been updated.
|
|
@@ -303,9 +303,9 @@ class Shrine
|
|
|
303
303
|
class Derivation::Url < Derivation::Command
|
|
304
304
|
delegate :name, :args, :source, :secret_key, :signer
|
|
305
305
|
|
|
306
|
-
def call(host: nil, prefix: nil, metadata: [], **)
|
|
306
|
+
def call(host: nil, prefix: nil, metadata: [], format: nil, **)
|
|
307
307
|
base_url = [host, *prefix].join("/")
|
|
308
|
-
path = path_identifier(metadata:)
|
|
308
|
+
path = path_identifier(metadata:, format:)
|
|
309
309
|
|
|
310
310
|
if signer
|
|
311
311
|
url = [base_url, path].join("/")
|
|
@@ -318,12 +318,13 @@ class Shrine
|
|
|
318
318
|
|
|
319
319
|
private
|
|
320
320
|
|
|
321
|
-
def path_identifier(metadata: [])
|
|
322
|
-
[
|
|
321
|
+
def path_identifier(metadata: [], format: nil)
|
|
322
|
+
path = [
|
|
323
323
|
name,
|
|
324
324
|
*args,
|
|
325
325
|
source.urlsafe_dump(metadata:)
|
|
326
326
|
].map{|component| Rack::Utils.escape_path(component.to_s)}.join('/')
|
|
327
|
+
format ? "#{path}.#{format}" : path
|
|
327
328
|
end
|
|
328
329
|
|
|
329
330
|
def query(expires_in: nil,
|
|
@@ -386,6 +387,7 @@ class Shrine
|
|
|
386
387
|
check_expiry!(request)
|
|
387
388
|
|
|
388
389
|
name, *args, serialized_file = request.path_info.split("/")[1..-1]
|
|
390
|
+
serialized_file = serialized_file.sub(/\.\w+$/, "")
|
|
389
391
|
|
|
390
392
|
name = name.to_sym
|
|
391
393
|
uploaded_file = shrine_class::UploadedFile.urlsafe_load(serialized_file)
|
|
@@ -49,14 +49,14 @@ class Shrine
|
|
|
49
49
|
# "Content-Disposition" headers, whose values are extracted from
|
|
50
50
|
# metadata. Also returns the correct "Content-Range" header on ranged
|
|
51
51
|
# requests.
|
|
52
|
-
def rack_headers(filename: nil, type: nil, disposition: "inline", range: false)
|
|
52
|
+
def rack_headers(filename: nil, type: nil, disposition: "inline", range: false, etag: nil)
|
|
53
53
|
{
|
|
54
54
|
"Content-Length" => content_length(range),
|
|
55
55
|
"Content-Type" => content_type(type),
|
|
56
56
|
"Content-Disposition" => content_disposition(disposition, filename),
|
|
57
57
|
"Content-Range" => content_range(range),
|
|
58
58
|
"Accept-Ranges" => accept_ranges(range),
|
|
59
|
-
"ETag" => etag,
|
|
59
|
+
"ETag" => etag || self.etag,
|
|
60
60
|
}.compact
|
|
61
61
|
end
|
|
62
62
|
|
data/lib/shrine/version.rb
CHANGED
data/shrine.gemspec
CHANGED
|
@@ -67,10 +67,10 @@ direct uploads for fully asynchronous user experience.
|
|
|
67
67
|
|
|
68
68
|
# for instrumentation plugin
|
|
69
69
|
gem.add_development_dependency "dry-monitor"
|
|
70
|
-
gem.add_development_dependency "activesupport", RUBY_ENGINE == "jruby" ? "~> 7.
|
|
70
|
+
gem.add_development_dependency "activesupport", RUBY_ENGINE == "jruby" ? "~> 7.2" : "~> 8.1"
|
|
71
71
|
|
|
72
72
|
# for ORM plugins
|
|
73
73
|
gem.add_development_dependency "sequel"
|
|
74
|
-
gem.add_development_dependency "activerecord", RUBY_ENGINE == "jruby" ? "~> 7.
|
|
74
|
+
gem.add_development_dependency "activerecord", RUBY_ENGINE == "jruby" ? "~> 7.2" : "~> 8.1"
|
|
75
75
|
gem.add_development_dependency "sqlite3", "~> 2.1" unless RUBY_ENGINE == "jruby"
|
|
76
76
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: shrine
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.7.
|
|
4
|
+
version: 3.7.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Janko Marohnić
|
|
@@ -482,6 +482,7 @@ files:
|
|
|
482
482
|
- doc/release_notes/3.5.0.md
|
|
483
483
|
- doc/release_notes/3.6.0.md
|
|
484
484
|
- doc/release_notes/3.7.0.md
|
|
485
|
+
- doc/release_notes/3.7.1.md
|
|
485
486
|
- doc/retrieving_uploads.md
|
|
486
487
|
- doc/securing_uploads.md
|
|
487
488
|
- doc/storage/file_system.md
|
|
@@ -575,7 +576,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
575
576
|
- !ruby/object:Gem::Version
|
|
576
577
|
version: '0'
|
|
577
578
|
requirements: []
|
|
578
|
-
rubygems_version:
|
|
579
|
+
rubygems_version: 3.6.9
|
|
579
580
|
specification_version: 4
|
|
580
581
|
summary: Toolkit for file attachments in Ruby applications
|
|
581
582
|
test_files: []
|