activestorage_database 1.0 → 2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c09c92d2e2f7584a58c68836d5f6a946ec84ec0482b071fe6c1db4d3107bae9
4
- data.tar.gz: fc7202ce7879b163a75fb0719c12e2de79d53deb79afca1d13c67a24edc28307
3
+ metadata.gz: 7fa7b57feb6093ab0bb2d10ee4fac66829699f02ab1ef3ec49299ba6ae0ad8ca
4
+ data.tar.gz: f29f8e16e2c3f445bedfba0984ca7775ff04f584a4749ec92ddf7153a2c3d1d9
5
5
  SHA512:
6
- metadata.gz: 171507085f3e4db49773b71c72e79e0b8e9c4160fb3085fd70546bc914597b8e9c059d9fe3568a651ef7e0a63770762ff777b4b30064d112bdd3a77cc69116eb
7
- data.tar.gz: 405ada0a3112021aa408f46fda10aa610ccb7381b3feab730072ce370470dca545dd3239a88e92e3616de06830a0dfa8a4e0f3da27d07046d44dfbb527cd131e
6
+ metadata.gz: b163055124e6fd50d9d6546a0cb92d967541afd0d19b0d31bcff8ac0a2051cc0939bd8082b1ff2ab98b82d4abfc461e87a0d62f14642719804c0deac3b9caf6a
7
+ data.tar.gz: 93ba877681b403de773931c412c184f2c463e5d9595f6dc2c3af628bb47a40bb2594c7a2db4f437c7abd7647097e3316b65da2bd5f3dd1707dbff35dffe3fbc0
@@ -4,7 +4,7 @@ module ActiveStorage
4
4
  class Service::DatabaseService < Service
5
5
  CHUNK_SIZE = 1.megabytes.freeze
6
6
 
7
- def upload(key, io, checksum: nil, **options)
7
+ def upload(key, io, checksum: nil, **)
8
8
  instrument :upload, key: key, checksum: checksum do
9
9
  file = ActivestorageDatabase::File.create!(key: key, data: io.read)
10
10
  ensure_integrity_of(key, checksum) if checksum
@@ -65,19 +65,8 @@ module ActiveStorage
65
65
  expires_in: expires_in,
66
66
  purpose: :blob_key
67
67
  )
68
- current_uri = URI.parse(current_host)
69
- generated_url = url_helpers.service_url(
70
- verified_key_with_expiration,
71
- protocol: current_uri.scheme,
72
- host: current_uri.host,
73
- port: current_uri.port,
74
- disposition: content_disposition,
75
- content_type: content_type,
76
- filename: filename
77
- )
78
- payload[:url] = generated_url
79
68
 
80
- generated_url
69
+ url_helpers.service_url(verified_key_with_expiration, filename: filename, **url_options)
81
70
  end
82
71
  end
83
72
 
@@ -93,13 +82,10 @@ module ActiveStorage
93
82
  expires_in: expires_in,
94
83
  purpose: :blob_token
95
84
  )
96
- generated_url = url_helpers.update_service_url(
97
- verified_token_with_expiration,
98
- host: current_host
99
- )
100
- payload[:url] = generated_url
101
85
 
102
- generated_url
86
+ url_helpers.update_service_url(verified_token_with_expiration, url_options) do |generated_url|
87
+ payload[:url] = generated_url
88
+ end
103
89
  end
104
90
  end
105
91
 
@@ -108,11 +94,10 @@ module ActiveStorage
108
94
  end
109
95
 
110
96
  private
111
- def current_host
112
- ActiveStorage::Current.host
97
+ def url_options
98
+ ActiveStorage::Current.url_options
113
99
  end
114
100
 
115
-
116
101
  def ensure_integrity_of(key, checksum)
117
102
  file = ::ActivestorageDatabase::File.find_by(key: key)
118
103
  return if Digest::MD5.base64digest(file.data) == checksum
@@ -1,3 +1,3 @@
1
1
  module ActivestorageDatabase
2
- VERSION = "1.0"
2
+ VERSION = "2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activestorage_database
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.0'
4
+ version: '2.0'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dino Maric
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: 6.0.0
20
+ version: '7.0'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: 6.0.0
27
+ version: '7.0'
28
28
  description: Store ActiveStorage attachments inside the database.
29
29
  email:
30
30
  - dinom@hey.com