active_storage-cloud_transformations 0.2.5 → 0.3.0

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: c56a1a41f5c7b3da1cfb6a288b3cc1ea2f8da13700df65401f9b6d90ca706c2f
4
- data.tar.gz: '069f48bd03f818fcbab6cd8839013c045f4a3f34e8146ab15b55863caa562647'
3
+ metadata.gz: d9ffa075ea0830d2c76a32bd0ebe9e86799859e0bc741ce3128b217b7dc25b79
4
+ data.tar.gz: bfcd4614b55c2cba811263826d178d661bcefb91f50d53996721ab8792ee38d6
5
5
  SHA512:
6
- metadata.gz: f72a1d55d57627bb772ea34c303dcc26f558907d0aebd790b6a8323a472e4af21919f798f506ddf24c876ab9413371c314ffdb71e1c7066aada401fe807020c5
7
- data.tar.gz: 272063e142c02003bc0733157c691246f484759d45f0fd6b088c709211c1a1dc3574b7e90c94e369e86065641ea43b1d89235175ec82e020234fd5eae4111918
6
+ metadata.gz: a2fafbe7f41f231d20303261ed9863e56ba33b7de17ba009374934e8d93fbcddd7091a58f572fad3667a1efdd189ffa608e6a68a9b8386f1cc559d635ee7906d
7
+ data.tar.gz: 40b5993c2cc8933c6bae0cd9f61c144aefdc3996b0356889beb882fe387e69c21d339ac5a663e00f4ebe6d4c8f308930b4e9e20c9b5849ade857d85505b72043
@@ -2,7 +2,6 @@ module ActiveStorage
2
2
  module CloudTransformations
3
3
  class Preview < ActiveStorage::Preview
4
4
  def process
5
- # TODO
6
5
  # if image.attached?
7
6
  # if image.variant(variation).processed?
8
7
  # variant
@@ -10,8 +9,9 @@ module ActiveStorage
10
9
  # create_blob_preview_image_variant
11
10
  # end
12
11
  # else
12
+ if !blob.preview_image.attached?
13
13
  create_blob_preview_image_and_blob_preview_image_variant
14
- # end
14
+ end
15
15
  self
16
16
  end
17
17
 
@@ -6,22 +6,18 @@ module ActiveStorage
6
6
  def process
7
7
  raise ActiveStorage::InvariableError unless blob.image? || blob.video?
8
8
 
9
- role = ActiveRecord.respond_to?(:writing_role) ? ActiveRecord.writing_role : ActiveRecord::Base.writing_role
10
- ActiveRecord::Base.connected_to(role: role) do
11
- # FIXME #create_or_find_by! runs the block in both cases. bug in rails?
12
- blob.variant_records.find_or_create_by!(variation_digest: variation.digest) do |record|
13
- output_blob = ActiveStorage::Blob.create_before_direct_upload!(**{
14
- filename: "#{blob.filename.base}.#{variation.format}",
15
- content_type: variation.content_type,
16
- service_name: blob.service_name,
17
- byte_size: 0, # we don"t know this yet, can we get it from the results?
18
- checksum: 0, # we don"t know this yet, can we get it from the results?
19
- })
20
- output_blob.metadata[:analyzed] = true
21
- record.image.attach(output_blob)
22
- run_crucible_job(blob, output_blob, ignore_timeouts: true)
23
- ActiveStorage::AnalyzeJob.perform_later(output_blob)
24
- end
9
+ blob.variant_records.find_or_create_by!(variation_digest: variation.digest) do |record|
10
+ output_blob = ActiveStorage::Blob.create_before_direct_upload!(**{
11
+ filename: "#{blob.filename.base}.#{variation.format}",
12
+ content_type: variation.content_type,
13
+ service_name: blob.service_name,
14
+ byte_size: 0, # we don"t know this yet, can we get it from the results?
15
+ checksum: 0, # we don"t know this yet, can we get it from the results?
16
+ })
17
+ output_blob.metadata[:analyzed] = true
18
+ record.image.attach(output_blob)
19
+ run_crucible_job(blob, output_blob, ignore_timeouts: true)
20
+ ActiveStorage::AnalyzeJob.perform_later(output_blob)
25
21
  end
26
22
  rescue ActiveRecord::RecordNotUnique
27
23
  retry
@@ -41,12 +37,14 @@ module ActiveStorage
41
37
  def run_crucible_job input_blob, output_blob, ignore_timeouts: false
42
38
  width, height = variation.transformations.fetch(:resize_to_limit)
43
39
  rotation = variation.transformations.fetch(:rotation, 0)
44
- post! "https://huuabwxpqf.execute-api.us-west-2.amazonaws.com/prod/#{path}", {
40
+ params = {
45
41
  blob_url: input_blob.url.split("?").first,
46
42
  dimensions: "#{width}x#{height}",
47
43
  rotation: rotation,
48
44
  variant_url: output_blob.url.split("?").first,
49
- }, ignore_timeouts: ignore_timeouts
45
+ format: format,
46
+ }
47
+ post! "https://huuabwxpqf.execute-api.us-west-2.amazonaws.com/prod/#{path}", params, ignore_timeouts: ignore_timeouts
50
48
  end
51
49
 
52
50
  def path
@@ -1,5 +1,5 @@
1
1
  module ActiveStorage
2
2
  module CloudTransformations
3
- VERSION = "0.2.5"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_storage-cloud_transformations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micah Geisel
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-10-08 00:00:00.000000000 Z
11
+ date: 2024-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activestorage