active_storage-postgresql 0.2.1 → 0.3.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 +4 -4
- data/lib/active_storage/postgresql/version.rb +1 -1
- data/lib/active_storage/service/postgresql_service.rb +34 -11
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1212a9c234be19bf6444a03c0bdf66ab92397ad4527ac9e0ce029d0440724a34
|
4
|
+
data.tar.gz: 7ca4cb2634cac459ee8caf886887293f69d00f989128a41d108b3023bf6ee7e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6773b507eae6af885133918d77876e310b946f19221aeeea2a4b122805b852699350d86556a0b04e0dbdd3dda98def4580756e51af0bc44f2611afe45209b04d
|
7
|
+
data.tar.gz: 6b1617c425df194ae4bcf2b415e11fd8cb16eb76698677036a7a981188120dd71ece4a6307654a336a74d86327cb94bb7fc223347f4db973f9f9e87aff8be944
|
@@ -6,7 +6,8 @@ module ActiveStorage
|
|
6
6
|
# Wraps a PostgreSQL database as an Active Storage service. See ActiveStorage::Service for the generic API
|
7
7
|
# documentation that applies to all services.
|
8
8
|
class Service::PostgreSQLService < Service
|
9
|
-
def initialize(**options)
|
9
|
+
def initialize(public: false, **options)
|
10
|
+
@public = public
|
10
11
|
end
|
11
12
|
|
12
13
|
def upload(key, io, checksum: nil, **)
|
@@ -62,7 +63,25 @@ module ActiveStorage
|
|
62
63
|
end
|
63
64
|
end
|
64
65
|
|
65
|
-
def
|
66
|
+
def private_url(key, expires_in:, filename:, content_type:, disposition:, **)
|
67
|
+
generate_url(key, expires_in: expires_in, filename: filename, content_type: content_type, disposition: disposition)
|
68
|
+
end
|
69
|
+
|
70
|
+
def public_url(key, filename:, content_type: nil, disposition: :attachment, **)
|
71
|
+
generate_url(key, expires_in: nil, filename: filename, content_type: content_type, disposition: disposition)
|
72
|
+
end
|
73
|
+
|
74
|
+
def url(key, **options)
|
75
|
+
super
|
76
|
+
rescue NotImplementedError, ArgumentError
|
77
|
+
if @public
|
78
|
+
public_url(key, **options)
|
79
|
+
else
|
80
|
+
private_url(key, **options)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def generate_url(key, expires_in:, filename:, disposition:, content_type:)
|
66
85
|
instrument :url, key: key do |payload|
|
67
86
|
content_disposition = content_disposition_with(type: disposition, filename: filename)
|
68
87
|
verified_key_with_expiration = ActiveStorage.verifier.generate(
|
@@ -71,12 +90,12 @@ module ActiveStorage
|
|
71
90
|
disposition: content_disposition,
|
72
91
|
content_type: content_type
|
73
92
|
},
|
74
|
-
|
75
|
-
purpose: :blob_key
|
93
|
+
expires_in: expires_in,
|
94
|
+
purpose: :blob_key
|
76
95
|
)
|
77
96
|
|
78
97
|
generated_url = url_helpers.rails_postgresql_service_url(verified_key_with_expiration,
|
79
|
-
|
98
|
+
**url_options,
|
80
99
|
disposition: content_disposition,
|
81
100
|
content_type: content_type,
|
82
101
|
filename: filename
|
@@ -87,7 +106,7 @@ module ActiveStorage
|
|
87
106
|
end
|
88
107
|
end
|
89
108
|
|
90
|
-
def url_for_direct_upload(key, expires_in:, content_type:, content_length:, checksum:)
|
109
|
+
def url_for_direct_upload(key, expires_in:, content_type:, content_length:, checksum:, custom_metadata: {})
|
91
110
|
instrument :url, key: key do |payload|
|
92
111
|
verified_token_with_expiration = ActiveStorage.verifier.generate(
|
93
112
|
{
|
@@ -96,11 +115,11 @@ module ActiveStorage
|
|
96
115
|
content_length: content_length,
|
97
116
|
checksum: checksum
|
98
117
|
},
|
99
|
-
|
100
|
-
purpose: :blob_token
|
118
|
+
expires_in: expires_in,
|
119
|
+
purpose: :blob_token
|
101
120
|
)
|
102
121
|
|
103
|
-
generated_url = url_helpers.update_rails_postgresql_service_url(verified_token_with_expiration,
|
122
|
+
generated_url = url_helpers.update_rails_postgresql_service_url(verified_token_with_expiration, **url_options)
|
104
123
|
|
105
124
|
payload[:url] = generated_url
|
106
125
|
|
@@ -118,8 +137,12 @@ module ActiveStorage
|
|
118
137
|
@url_helpers ||= Rails.application.routes.url_helpers
|
119
138
|
end
|
120
139
|
|
121
|
-
def
|
122
|
-
ActiveStorage::Current.
|
140
|
+
def url_options
|
141
|
+
if ActiveStorage::Current.respond_to?(:url_options)
|
142
|
+
ActiveStorage::Current.url_options
|
143
|
+
else
|
144
|
+
{ host: ActiveStorage::Current.host }
|
145
|
+
end
|
123
146
|
end
|
124
147
|
end
|
125
148
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_storage-postgresql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lachlan Sylvester
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '6.0'
|
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: '
|
26
|
+
version: '6.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: pg
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.7'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: appraisal
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
description:
|
70
84
|
email:
|
71
85
|
- lachlan.sylvester@hypothetical.com.au
|
@@ -105,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
119
|
- !ruby/object:Gem::Version
|
106
120
|
version: '0'
|
107
121
|
requirements: []
|
108
|
-
rubygems_version: 3.
|
122
|
+
rubygems_version: 3.3.4
|
109
123
|
signing_key:
|
110
124
|
specification_version: 4
|
111
125
|
summary: PostgreSQL Adapter for Active Storage
|