activestorage 7.1.0.beta1 → 7.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5dfb6f1b9694161b8a664871f19104256c481525dbcd52a738137c2fdb0e7c55
4
- data.tar.gz: f72483c9153ef5bae19222f6ccb659d7d6ee0444d8785a00f9fa54c12f0a861b
3
+ metadata.gz: 79c8988a45e8280a067b54409493156d3f0082a0570a8cd40b2eb21e659abd2e
4
+ data.tar.gz: f15469f66619c2141f9eadc71a495febf9bd21072f26805b70114dd7a94b21da
5
5
  SHA512:
6
- metadata.gz: c7fb7bd0ff896ca2f063a71cbc2187659b14b819d6899c23c48ad43ce54f4a48a4039c027e7802a551986b9f0cbde296e4acf9f633aacaf886a3608a3902a07d
7
- data.tar.gz: 438c8ad07e00b2bdcee84b781bf764fb4c209999e3ccb757b41c5c7c4b9d32f26ea5c36b8f820bd7f1c3b1901ae088448e92b09ff340528636eef841a62df7f4
6
+ metadata.gz: 0b40b13eeb142be13e379776368c4aa4ea3804e4ba9f9a5996a20e184290d8fa6c3a298e344154f29c22d1ae2ef64ce66b5bc1c7911355afbaf6487e1ce39c93
7
+ data.tar.gz: 4b873cdea36ba4ae277f03f26a0913d4617a3f34f1add8ba7fa3d4f8966384dd5e389ec0d6dd1d043bd340134953562a412ab403b864e3d9dc57801ec4755faa
data/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ ## Rails 7.1.0.rc1 (September 27, 2023) ##
2
+
3
+ * Add `expires_at` option to `ActiveStorage::Blob#signed_id`.
4
+
5
+ ```ruby
6
+ rails_blob_path(user.avatar, disposition: "attachment", expires_at: 30.minutes.from_now)
7
+ <%= image_tag rails_blob_path(user.avatar.variant(resize: "100x100"), expires_at: 30.minutes.from_now) %>
8
+ ```
9
+
10
+ *Aki*
11
+
12
+ * Allow attaching File and Pathname when assigning attributes, e.g.
13
+
14
+ ```ruby
15
+ User.create!(avatar: File.open("image.jpg"))
16
+ User.create!(avatar: file_fixture("image.jpg"))
17
+ ```
18
+
19
+ *Dorian Marié*
20
+
21
+
1
22
  ## Rails 7.1.0.beta1 (September 13, 2023) ##
2
23
 
3
24
  * Disables the session in `ActiveStorage::Blobs::ProxyController`
@@ -5,7 +5,7 @@ class ActiveStorage::AnalyzeJob < ActiveStorage::BaseJob
5
5
  queue_as { ActiveStorage.queues[:analysis] }
6
6
 
7
7
  discard_on ActiveRecord::RecordNotFound
8
- retry_on ActiveStorage::IntegrityError, attempts: 10, wait: :exponentially_longer
8
+ retry_on ActiveStorage::IntegrityError, attempts: 10, wait: :polynomially_longer
9
9
 
10
10
  def perform(blob)
11
11
  blob.analyze
@@ -7,7 +7,7 @@ class ActiveStorage::MirrorJob < ActiveStorage::BaseJob
7
7
  queue_as { ActiveStorage.queues[:mirror] }
8
8
 
9
9
  discard_on ActiveStorage::FileNotFoundError
10
- retry_on ActiveStorage::IntegrityError, attempts: 10, wait: :exponentially_longer
10
+ retry_on ActiveStorage::IntegrityError, attempts: 10, wait: :polynomially_longer
11
11
 
12
12
  def perform(key, checksum:)
13
13
  ActiveStorage::Blob.service.try(:mirror, key, checksum: checksum)
@@ -5,7 +5,7 @@ class ActiveStorage::PurgeJob < ActiveStorage::BaseJob
5
5
  queue_as { ActiveStorage.queues[:purge] }
6
6
 
7
7
  discard_on ActiveRecord::RecordNotFound
8
- retry_on ActiveRecord::Deadlocked, attempts: 10, wait: :exponentially_longer
8
+ retry_on ActiveRecord::Deadlocked, attempts: 10, wait: :polynomially_longer
9
9
 
10
10
  def perform(blob)
11
11
  blob.purge
@@ -4,7 +4,7 @@ class ActiveStorage::TransformJob < ActiveStorage::BaseJob
4
4
  queue_as { ActiveStorage.queues[:transform] }
5
5
 
6
6
  discard_on ActiveRecord::RecordNotFound
7
- retry_on ActiveStorage::IntegrityError, attempts: 10, wait: :exponentially_longer
7
+ retry_on ActiveStorage::IntegrityError, attempts: 10, wait: :polynomially_longer
8
8
 
9
9
  def perform(blob, transformations)
10
10
  blob.variant(transformations).processed
@@ -158,7 +158,7 @@ class ActiveStorage::Blob < ActiveStorage::Record
158
158
  end
159
159
 
160
160
  # Returns a signed ID for this blob that's suitable for reference on the client-side without fear of tampering.
161
- def signed_id(purpose: :blob_id, expires_in: nil)
161
+ def signed_id(purpose: :blob_id, expires_in: nil, expires_at: nil)
162
162
  super
163
163
  end
164
164
 
data/config/routes.rb CHANGED
@@ -32,16 +32,17 @@ Rails.application.routes.draw do
32
32
 
33
33
  direct :rails_storage_proxy do |model, options|
34
34
  expires_in = options.delete(:expires_in) { ActiveStorage.urls_expire_in }
35
+ expires_at = options.delete(:expires_at)
35
36
 
36
37
  if model.respond_to?(:signed_id)
37
38
  route_for(
38
39
  :rails_service_blob_proxy,
39
- model.signed_id(expires_in: expires_in),
40
+ model.signed_id(expires_in: expires_in, expires_at: expires_at),
40
41
  model.filename,
41
42
  options
42
43
  )
43
44
  else
44
- signed_blob_id = model.blob.signed_id(expires_in: expires_in)
45
+ signed_blob_id = model.blob.signed_id(expires_in: expires_in, expires_at: expires_at)
45
46
  variation_key = model.variation.key
46
47
  filename = model.blob.filename
47
48
 
@@ -57,16 +58,17 @@ Rails.application.routes.draw do
57
58
 
58
59
  direct :rails_storage_redirect do |model, options|
59
60
  expires_in = options.delete(:expires_in) { ActiveStorage.urls_expire_in }
61
+ expires_at = options.delete(:expires_at)
60
62
 
61
63
  if model.respond_to?(:signed_id)
62
64
  route_for(
63
65
  :rails_service_blob,
64
- model.signed_id(expires_in: expires_in),
66
+ model.signed_id(expires_in: expires_in, expires_at: expires_at),
65
67
  model.filename,
66
68
  options
67
69
  )
68
70
  else
69
- signed_blob_id = model.blob.signed_id(expires_in: expires_in)
71
+ signed_blob_id = model.blob.signed_id(expires_in: expires_in, expires_at: expires_at)
70
72
  variation_key = model.variation.key
71
73
  filename = model.blob.filename
72
74
 
@@ -30,6 +30,18 @@ module ActiveStorage
30
30
  )
31
31
  when Hash
32
32
  blob.upload_without_unfurling(attachable.fetch(:io))
33
+ when File
34
+ blob.upload_without_unfurling(attachable)
35
+ when Pathname
36
+ blob.upload_without_unfurling(attachable.open)
37
+ when ActiveStorage::Blob
38
+ when String
39
+ else
40
+ raise(
41
+ ArgumentError,
42
+ "Could not upload: expected attachable, " \
43
+ "got #{attachable.inspect}"
44
+ )
33
45
  end
34
46
  end
35
47
 
@@ -82,8 +94,26 @@ module ActiveStorage
82
94
  )
83
95
  when String
84
96
  ActiveStorage::Blob.find_signed!(attachable, record: record)
97
+ when File
98
+ ActiveStorage::Blob.build_after_unfurling(
99
+ io: attachable,
100
+ filename: File.basename(attachable),
101
+ record: record,
102
+ service_name: attachment_service_name
103
+ )
104
+ when Pathname
105
+ ActiveStorage::Blob.build_after_unfurling(
106
+ io: attachable.open,
107
+ filename: File.basename(attachable),
108
+ record: record,
109
+ service_name: attachment_service_name
110
+ )
85
111
  else
86
- raise ArgumentError, "Could not find or build blob: expected attachable, got #{attachable.inspect}"
112
+ raise(
113
+ ArgumentError,
114
+ "Could not find or build blob: expected attachable, " \
115
+ "got #{attachable.inspect}"
116
+ )
87
117
  end
88
118
  end
89
119
 
@@ -10,7 +10,7 @@ module ActiveStorage
10
10
  MAJOR = 7
11
11
  MINOR = 1
12
12
  TINY = 0
13
- PRE = "beta1"
13
+ PRE = "rc1"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activestorage
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.1.0.beta1
4
+ version: 7.1.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-13 00:00:00.000000000 Z
11
+ date: 2023-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,56 +16,56 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 7.1.0.beta1
19
+ version: 7.1.0.rc1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 7.1.0.beta1
26
+ version: 7.1.0.rc1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: actionpack
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 7.1.0.beta1
33
+ version: 7.1.0.rc1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 7.1.0.beta1
40
+ version: 7.1.0.rc1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: activejob
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 7.1.0.beta1
47
+ version: 7.1.0.rc1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 7.1.0.beta1
54
+ version: 7.1.0.rc1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: activerecord
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 7.1.0.beta1
61
+ version: 7.1.0.rc1
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: 7.1.0.beta1
68
+ version: 7.1.0.rc1
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: marcel
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -188,10 +188,10 @@ licenses:
188
188
  - MIT
189
189
  metadata:
190
190
  bug_tracker_uri: https://github.com/rails/rails/issues
191
- changelog_uri: https://github.com/rails/rails/blob/v7.1.0.beta1/activestorage/CHANGELOG.md
192
- documentation_uri: https://api.rubyonrails.org/v7.1.0.beta1/
191
+ changelog_uri: https://github.com/rails/rails/blob/v7.1.0.rc1/activestorage/CHANGELOG.md
192
+ documentation_uri: https://api.rubyonrails.org/v7.1.0.rc1/
193
193
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
194
- source_code_uri: https://github.com/rails/rails/tree/v7.1.0.beta1/activestorage
194
+ source_code_uri: https://github.com/rails/rails/tree/v7.1.0.rc1/activestorage
195
195
  rubygems_mfa_required: 'true'
196
196
  post_install_message:
197
197
  rdoc_options: []