active_storage-crucible 0.1.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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2656213e02772d6fa0094857594ad926a718ea12896b9d0398bee0daefe575f6
|
|
4
|
+
data.tar.gz: e78728082130e9daec29363ce14551a96decb246ebed19f288dd2ba94b2cd6c3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 86a2e01e5d41443a985d0bbf9b8ac362cd2838427f4f96a0b507ccf6b2921d63d3d9dd967cf35ff375d2faede45b6980f10f3bacce02e5e74e5d7e8f0fec3a9f
|
|
7
|
+
data.tar.gz: 4df7ad1ccc4bb0eaf58025f12b7785aa5247757a265d3220763700d691d80a94f3d646cb4218c8abf622128d215cbabf7d6a974626753744e9329ebc74fa78de
|
data/README.md
CHANGED
|
@@ -21,6 +21,7 @@ Requires an S3-compatible storage service (the gem generates presigned URLs for
|
|
|
21
21
|
```ruby
|
|
22
22
|
# config/initializers/crucible.rb
|
|
23
23
|
ActiveStorage::Crucible.endpoint = "https://crucible.example.com"
|
|
24
|
+
ActiveStorage::Crucible.api_token = "..."
|
|
24
25
|
```
|
|
25
26
|
|
|
26
27
|
Or with a block:
|
|
@@ -28,9 +29,16 @@ Or with a block:
|
|
|
28
29
|
```ruby
|
|
29
30
|
ActiveStorage::Crucible.configure do |config|
|
|
30
31
|
config.endpoint = ENV["CRUCIBLE_ENDPOINT"]
|
|
32
|
+
config.api_token = ENV["CRUCIBLE_API_TOKEN"]
|
|
31
33
|
end
|
|
32
34
|
```
|
|
33
35
|
|
|
36
|
+
Crucible requires the token on every request and answers `401` without it, so
|
|
37
|
+
`api_token` must be set to the value in that Crucible deployment's encrypted
|
|
38
|
+
credentials. It belongs with the endpoint: each deployment has its own token, so
|
|
39
|
+
an app that talks to more than one (staging vs. production, say) must set the
|
|
40
|
+
pair together.
|
|
41
|
+
|
|
34
42
|
## Usage
|
|
35
43
|
|
|
36
44
|
### Image and Video Variants
|
|
@@ -10,7 +10,7 @@ module ActiveStorage
|
|
|
10
10
|
uri = URI.parse(url)
|
|
11
11
|
http = Net::HTTP.new(uri.host, uri.port)
|
|
12
12
|
http.use_ssl = uri.scheme == "https"
|
|
13
|
-
request = Net::HTTP::Post.new(uri.request_uri,
|
|
13
|
+
request = Net::HTTP::Post.new(uri.request_uri, headers)
|
|
14
14
|
request.body = body.to_json
|
|
15
15
|
response = http.request(request)
|
|
16
16
|
unless response.code.start_with?("2")
|
|
@@ -18,6 +18,15 @@ module ActiveStorage
|
|
|
18
18
|
end
|
|
19
19
|
response
|
|
20
20
|
end
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
def headers
|
|
25
|
+
headers = { "Content-Type": "application/json" }
|
|
26
|
+
token = Crucible.api_token
|
|
27
|
+
headers[:Authorization] = "Bearer #{token}" if token.present?
|
|
28
|
+
headers
|
|
29
|
+
end
|
|
21
30
|
end
|
|
22
31
|
end
|
|
23
32
|
end
|
|
@@ -9,6 +9,7 @@ module ActiveStorage
|
|
|
9
9
|
blob.url(expires_in: expires_in)
|
|
10
10
|
when :put
|
|
11
11
|
service = blob.service
|
|
12
|
+
service = service.primary if service.respond_to?(:primary)
|
|
12
13
|
object = service.send(:object_for, blob.key)
|
|
13
14
|
object.presigned_url(:put, expires_in: expires_in.to_i, content_type: blob.content_type)
|
|
14
15
|
end
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: active_storage-crucible
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Micah Geisel
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-
|
|
10
|
+
date: 2026-08-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: activestorage
|