active_storage-postgresql 0.2.1 → 0.3.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02acf670378aa84368856711199795b7af498576ec9532dbbe16042d4e8ac470
|
4
|
+
data.tar.gz: 602293dce4f6ec595566c6ce67c997c54116d9dd4d1ac6294e8bdf3edd52364e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 551113a522736f182a02dce862bbc980eb0b244d757093ca67b27c7ccb3d66c580e47970b0fb3a95366c7a71cf2bdc9645f3bc09e9d4a5ea02b7e9c8967e4261
|
7
|
+
data.tar.gz: 3cddd9c9dbd5018c1efb06a72157bd2a0bc4c246a747fb6dd805882d95222e93969718e025892242cbb5ed5e6f94d50eb7ff2519c7a94de489dcc42b0553e71a
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# ActiveStorage::PostgreSQL
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/active_storage-postgresql.svg)](https://badge.fury.io/rb/active_storage-postgresql)
|
4
|
-
[![Build Status](https://travis-ci.com/lsylvester/active_storage-postgresql.svg?branch=
|
4
|
+
[![Build Status](https://travis-ci.com/lsylvester/active_storage-postgresql.svg?branch=main)](https://travis-ci.com/lsylvester/active_storage-postgresql)
|
5
5
|
|
6
6
|
ActiveStorage Service to store files PostgeSQL.
|
7
7
|
|
@@ -51,4 +51,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
51
51
|
|
52
52
|
## Code of Conduct
|
53
53
|
|
54
|
-
Everyone interacting in the ActiveStorage::PostgreSQL project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/lsylvester/active_storage-postgresql/blob/
|
54
|
+
Everyone interacting in the ActiveStorage::PostgreSQL project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/lsylvester/active_storage-postgresql/blob/main/CODE_OF_CONDUCT.md).
|
@@ -11,8 +11,8 @@ class ActiveStorage::PostgresqlController < ActiveStorage::BaseController
|
|
11
11
|
|
12
12
|
def show
|
13
13
|
if key = decode_verified_key
|
14
|
-
response.headers["Content-Type"] =
|
15
|
-
response.headers["Content-Disposition"] =
|
14
|
+
response.headers["Content-Type"] = key[:content_type] || DEFAULT_SEND_FILE_TYPE
|
15
|
+
response.headers["Content-Disposition"] = key[:disposition] || DEFAULT_SEND_FILE_DISPOSITION
|
16
16
|
size = ActiveStorage::PostgreSQL::File.open(key[:key], &:size)
|
17
17
|
|
18
18
|
ranges = Rack::Utils.get_byte_ranges(request.get_header('HTTP_RANGE'), size)
|
@@ -1,12 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'active_storage/postgresql/file'
|
4
|
-
|
5
3
|
module ActiveStorage
|
6
4
|
# Wraps a PostgreSQL database as an Active Storage service. See ActiveStorage::Service for the generic API
|
7
5
|
# documentation that applies to all services.
|
8
6
|
class Service::PostgreSQLService < Service
|
9
|
-
def initialize(**options)
|
7
|
+
def initialize(public: false, **options)
|
8
|
+
@public = public
|
10
9
|
end
|
11
10
|
|
12
11
|
def upload(key, io, checksum: nil, **)
|
@@ -62,7 +61,25 @@ module ActiveStorage
|
|
62
61
|
end
|
63
62
|
end
|
64
63
|
|
65
|
-
def
|
64
|
+
def private_url(key, expires_in:, filename:, content_type:, disposition:, **)
|
65
|
+
generate_url(key, expires_in: expires_in, filename: filename, content_type: content_type, disposition: disposition)
|
66
|
+
end
|
67
|
+
|
68
|
+
def public_url(key, filename:, content_type: nil, disposition: :attachment, **)
|
69
|
+
generate_url(key, expires_in: nil, filename: filename, content_type: content_type, disposition: disposition)
|
70
|
+
end
|
71
|
+
|
72
|
+
def url(key, **options)
|
73
|
+
super
|
74
|
+
rescue NotImplementedError, ArgumentError
|
75
|
+
if @public
|
76
|
+
public_url(key, **options)
|
77
|
+
else
|
78
|
+
private_url(key, **options)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def generate_url(key, expires_in:, filename:, disposition:, content_type:)
|
66
83
|
instrument :url, key: key do |payload|
|
67
84
|
content_disposition = content_disposition_with(type: disposition, filename: filename)
|
68
85
|
verified_key_with_expiration = ActiveStorage.verifier.generate(
|
@@ -71,12 +88,12 @@ module ActiveStorage
|
|
71
88
|
disposition: content_disposition,
|
72
89
|
content_type: content_type
|
73
90
|
},
|
74
|
-
|
75
|
-
purpose: :blob_key
|
91
|
+
expires_in: expires_in,
|
92
|
+
purpose: :blob_key
|
76
93
|
)
|
77
94
|
|
78
95
|
generated_url = url_helpers.rails_postgresql_service_url(verified_key_with_expiration,
|
79
|
-
|
96
|
+
**url_options,
|
80
97
|
disposition: content_disposition,
|
81
98
|
content_type: content_type,
|
82
99
|
filename: filename
|
@@ -87,7 +104,7 @@ module ActiveStorage
|
|
87
104
|
end
|
88
105
|
end
|
89
106
|
|
90
|
-
def url_for_direct_upload(key, expires_in:, content_type:, content_length:, checksum:)
|
107
|
+
def url_for_direct_upload(key, expires_in:, content_type:, content_length:, checksum:, custom_metadata: {})
|
91
108
|
instrument :url, key: key do |payload|
|
92
109
|
verified_token_with_expiration = ActiveStorage.verifier.generate(
|
93
110
|
{
|
@@ -96,11 +113,11 @@ module ActiveStorage
|
|
96
113
|
content_length: content_length,
|
97
114
|
checksum: checksum
|
98
115
|
},
|
99
|
-
|
100
|
-
purpose: :blob_token
|
116
|
+
expires_in: expires_in,
|
117
|
+
purpose: :blob_token
|
101
118
|
)
|
102
119
|
|
103
|
-
generated_url = url_helpers.update_rails_postgresql_service_url(verified_token_with_expiration,
|
120
|
+
generated_url = url_helpers.update_rails_postgresql_service_url(verified_token_with_expiration, **url_options)
|
104
121
|
|
105
122
|
payload[:url] = generated_url
|
106
123
|
|
@@ -118,8 +135,12 @@ module ActiveStorage
|
|
118
135
|
@url_helpers ||= Rails.application.routes.url_helpers
|
119
136
|
end
|
120
137
|
|
121
|
-
def
|
122
|
-
ActiveStorage::Current.
|
138
|
+
def url_options
|
139
|
+
if ActiveStorage::Current.respond_to?(:url_options)
|
140
|
+
ActiveStorage::Current.url_options
|
141
|
+
else
|
142
|
+
{ host: ActiveStorage::Current.host }
|
143
|
+
end
|
123
144
|
end
|
124
145
|
end
|
125
146
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lachlan Sylvester
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-07-13 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
|
@@ -31,6 +31,45 @@ dependencies:
|
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.0'
|
34
|
+
- - "!="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 1.3.0
|
37
|
+
- - "!="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 1.3.1
|
40
|
+
- - "!="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 1.3.2
|
43
|
+
- - "!="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.3.3
|
46
|
+
- - "!="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 1.3.4
|
49
|
+
- - "!="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: 1.3.5
|
52
|
+
- - "!="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.4.0
|
55
|
+
- - "!="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 1.4.1
|
58
|
+
- - "!="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 1.4.2
|
61
|
+
- - "!="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 1.4.3
|
64
|
+
- - "!="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 1.4.4
|
67
|
+
- - "!="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.4.5
|
70
|
+
- - "<"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '2.0'
|
34
73
|
type: :runtime
|
35
74
|
prerelease: false
|
36
75
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -38,6 +77,45 @@ dependencies:
|
|
38
77
|
- - ">="
|
39
78
|
- !ruby/object:Gem::Version
|
40
79
|
version: '1.0'
|
80
|
+
- - "!="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.3.0
|
83
|
+
- - "!="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.3.1
|
86
|
+
- - "!="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 1.3.2
|
89
|
+
- - "!="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: 1.3.3
|
92
|
+
- - "!="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 1.3.4
|
95
|
+
- - "!="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 1.3.5
|
98
|
+
- - "!="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: 1.4.0
|
101
|
+
- - "!="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.4.1
|
104
|
+
- - "!="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: 1.4.2
|
107
|
+
- - "!="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 1.4.3
|
110
|
+
- - "!="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 1.4.4
|
113
|
+
- - "!="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: 1.4.5
|
116
|
+
- - "<"
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '2.0'
|
41
119
|
- !ruby/object:Gem::Dependency
|
42
120
|
name: pry
|
43
121
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,7 +144,21 @@ dependencies:
|
|
66
144
|
- - "~>"
|
67
145
|
- !ruby/object:Gem::Version
|
68
146
|
version: '1.7'
|
69
|
-
|
147
|
+
- !ruby/object:Gem::Dependency
|
148
|
+
name: appraisal
|
149
|
+
requirement: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
|
+
type: :development
|
155
|
+
prerelease: false
|
156
|
+
version_requirements: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
description:
|
70
162
|
email:
|
71
163
|
- lachlan.sylvester@hypothetical.com.au
|
72
164
|
executables: []
|
@@ -90,7 +182,7 @@ homepage: https://github.com/lsylvester/active_storage-postgresql
|
|
90
182
|
licenses:
|
91
183
|
- MIT
|
92
184
|
metadata: {}
|
93
|
-
post_install_message:
|
185
|
+
post_install_message:
|
94
186
|
rdoc_options: []
|
95
187
|
require_paths:
|
96
188
|
- lib
|
@@ -105,8 +197,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
197
|
- !ruby/object:Gem::Version
|
106
198
|
version: '0'
|
107
199
|
requirements: []
|
108
|
-
rubygems_version: 3.0.
|
109
|
-
signing_key:
|
200
|
+
rubygems_version: 3.0.1
|
201
|
+
signing_key:
|
110
202
|
specification_version: 4
|
111
203
|
summary: PostgreSQL Adapter for Active Storage
|
112
204
|
test_files: []
|