uppy-s3_multipart 1.2.1 → 1.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/README.md +45 -30
- data/lib/uppy/s3_multipart/app.rb +2 -2
- data/lib/uppy/s3_multipart/client.rb +17 -4
- data/uppy-s3_multipart.gemspec +4 -6
- metadata +10 -42
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 74cc9df490db7f6381820d8cdede6aad9bf4ae883c124849ea69e7d596c1f3a8
|
|
4
|
+
data.tar.gz: 163f5cdf1ba930393f9029059abe3a7ad3534d68b9ee8aee3b7d2a5ccd9a482b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b59f29f7a88d8ce31f2d6ab4e0fdfe081cc5b0de982d600e4957e250afcf48f5d12585dc7974fb9c73b49282fc70474e306ad92b762ff367151fc98c5dda0598
|
|
7
|
+
data.tar.gz: e226b2b0c3f6fad19cc8b0705089563b0e9e119dbe89efee2fda7272b51b440c5e4cd8662bc6311b7a7411b59470335b2586438626e7cbaf6671ab94617b5827
|
data/README.md
CHANGED
|
@@ -22,36 +22,20 @@ following:
|
|
|
22
22
|
|
|
23
23
|
```json
|
|
24
24
|
[
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"ExposeHeaders": [
|
|
40
|
-
"ETag"
|
|
41
|
-
],
|
|
42
|
-
"MaxAgeSeconds": 3000
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
"AllowedHeaders": [],
|
|
46
|
-
"AllowedMethods": [
|
|
47
|
-
"GET"
|
|
48
|
-
],
|
|
49
|
-
"AllowedOrigins": [
|
|
50
|
-
"*"
|
|
51
|
-
],
|
|
52
|
-
"ExposeHeaders": [],
|
|
53
|
-
"MaxAgeSeconds": 3000
|
|
54
|
-
}
|
|
25
|
+
{
|
|
26
|
+
"AllowedHeaders": ["content-type", "x-amz-content-sha256", "x-amz-date"],
|
|
27
|
+
"AllowedMethods": ["GET", "POST", "PUT"],
|
|
28
|
+
"AllowedOrigins": ["https://my-app.com"],
|
|
29
|
+
"ExposeHeaders": ["ETag", "Location"],
|
|
30
|
+
"MaxAgeSeconds": 3000
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"AllowedHeaders": [],
|
|
34
|
+
"AllowedMethods": ["GET"],
|
|
35
|
+
"AllowedOrigins": ["*"],
|
|
36
|
+
"ExposeHeaders": [],
|
|
37
|
+
"MaxAgeSeconds": 3000
|
|
38
|
+
}
|
|
55
39
|
]
|
|
56
40
|
```
|
|
57
41
|
|
|
@@ -327,6 +311,37 @@ Shrine.storages = {
|
|
|
327
311
|
}
|
|
328
312
|
```
|
|
329
313
|
|
|
314
|
+
#### `:presigned_host`
|
|
315
|
+
|
|
316
|
+
The `:presigned_host` option overrides the host used when generating
|
|
317
|
+
presigned URLs (`#prepare_upload_part` and `#object_url`), while the rest of
|
|
318
|
+
the operations continue to use the endpoint configured on the `:bucket`
|
|
319
|
+
client.
|
|
320
|
+
|
|
321
|
+
This is useful when the S3-compatible endpoint reachable by your app isn't
|
|
322
|
+
the same one reachable by the browser, for example when running [Minio] in
|
|
323
|
+
Docker Compose and accessing it via a different host than the app container
|
|
324
|
+
does:
|
|
325
|
+
|
|
326
|
+
```rb
|
|
327
|
+
bucket = Aws::S3::Bucket.new(
|
|
328
|
+
name: "<MINIO_BUCKET>",
|
|
329
|
+
access_key_id: "<MINIO_ACCESS_KEY>",
|
|
330
|
+
secret_access_key: "<MINIO_SECRET_KEY>",
|
|
331
|
+
endpoint: "http://minio:9000", # reachable from the app container
|
|
332
|
+
region: "us-east-1",
|
|
333
|
+
force_path_style: true,
|
|
334
|
+
)
|
|
335
|
+
|
|
336
|
+
Uppy::S3Multipart::App.new(bucket: bucket, presigned_host: "localhost")
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
In the Shrine plugin it can be passed the same way as other options:
|
|
340
|
+
|
|
341
|
+
```rb
|
|
342
|
+
Shrine.uppy_s3_multipart(:cache, presigned_host: "localhost")
|
|
343
|
+
```
|
|
344
|
+
|
|
330
345
|
## Client
|
|
331
346
|
|
|
332
347
|
If you would rather implement the endpoints yourself, you can utilize the
|
|
@@ -8,9 +8,9 @@ require "securerandom"
|
|
|
8
8
|
module Uppy
|
|
9
9
|
module S3Multipart
|
|
10
10
|
class App
|
|
11
|
-
def initialize(bucket:, prefix: nil, public: nil, options: {})
|
|
11
|
+
def initialize(bucket:, prefix: nil, public: nil, options: {}, presigned_host: nil)
|
|
12
12
|
@router = Class.new(Router)
|
|
13
|
-
@router.opts[:client] = Client.new(bucket: bucket)
|
|
13
|
+
@router.opts[:client] = Client.new(bucket: bucket, presigned_host: presigned_host)
|
|
14
14
|
@router.opts[:prefix] = prefix
|
|
15
15
|
@router.opts[:public] = public
|
|
16
16
|
@router.opts[:options] = options
|
|
@@ -5,8 +5,9 @@ module Uppy
|
|
|
5
5
|
class Client
|
|
6
6
|
attr_reader :bucket
|
|
7
7
|
|
|
8
|
-
def initialize(bucket:)
|
|
9
|
-
@bucket
|
|
8
|
+
def initialize(bucket:, presigned_host: nil)
|
|
9
|
+
@bucket = bucket
|
|
10
|
+
@presigned_client = build_presigned_client(bucket.client, presigned_host) if presigned_host
|
|
10
11
|
end
|
|
11
12
|
|
|
12
13
|
def create_multipart_upload(key:, **options)
|
|
@@ -50,7 +51,7 @@ module Uppy
|
|
|
50
51
|
if public
|
|
51
52
|
object(key).public_url(**options)
|
|
52
53
|
else
|
|
53
|
-
object(key).
|
|
54
|
+
presigner.presigned_url(:get_object, bucket: bucket.name, key: object(key).key, **options)
|
|
54
55
|
end
|
|
55
56
|
end
|
|
56
57
|
|
|
@@ -72,7 +73,19 @@ module Uppy
|
|
|
72
73
|
end
|
|
73
74
|
|
|
74
75
|
def presigner
|
|
75
|
-
Aws::S3::Presigner.new(client: client)
|
|
76
|
+
Aws::S3::Presigner.new(client: @presigned_client || client)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def build_presigned_client(client, host)
|
|
80
|
+
endpoint = client.config.endpoint.dup
|
|
81
|
+
endpoint.host = host
|
|
82
|
+
|
|
83
|
+
Aws::S3::Client.new(
|
|
84
|
+
credentials: client.config.credentials,
|
|
85
|
+
region: client.config.region,
|
|
86
|
+
endpoint: endpoint,
|
|
87
|
+
force_path_style: client.config.force_path_style,
|
|
88
|
+
)
|
|
76
89
|
end
|
|
77
90
|
|
|
78
91
|
def client
|
data/uppy-s3_multipart.gemspec
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Gem::Specification.new do |gem|
|
|
2
2
|
gem.name = "uppy-s3_multipart"
|
|
3
|
-
gem.version = "1.
|
|
3
|
+
gem.version = "1.3.0"
|
|
4
4
|
|
|
5
|
-
gem.required_ruby_version = ">= 2.
|
|
5
|
+
gem.required_ruby_version = ">= 2.6"
|
|
6
6
|
|
|
7
7
|
gem.summary = "Provides a Rack application that implements endpoints for the AwsS3Multipart Uppy plugin."
|
|
8
8
|
gem.homepage = "https://github.com/janko/uppy-s3_multipart"
|
|
@@ -19,9 +19,7 @@ Gem::Specification.new do |gem|
|
|
|
19
19
|
|
|
20
20
|
gem.add_development_dependency "rake"
|
|
21
21
|
gem.add_development_dependency "minitest"
|
|
22
|
-
gem.add_development_dependency "rack-
|
|
23
|
-
gem.add_development_dependency "shrine", "~>
|
|
24
|
-
gem.add_development_dependency "shrine-memory"
|
|
25
|
-
gem.add_development_dependency "aws-sdk-core", "~> 3.23"
|
|
22
|
+
gem.add_development_dependency "rack-test", "~> 2.0"
|
|
23
|
+
gem.add_development_dependency "shrine", "~> 3.0"
|
|
26
24
|
gem.add_development_dependency "rexml"
|
|
27
25
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: uppy-s3_multipart
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Janko Marohnić
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: roda
|
|
@@ -87,61 +86,33 @@ dependencies:
|
|
|
87
86
|
- !ruby/object:Gem::Version
|
|
88
87
|
version: '0'
|
|
89
88
|
- !ruby/object:Gem::Dependency
|
|
90
|
-
name: rack-
|
|
91
|
-
requirement: !ruby/object:Gem::Requirement
|
|
92
|
-
requirements:
|
|
93
|
-
- - ">="
|
|
94
|
-
- !ruby/object:Gem::Version
|
|
95
|
-
version: '0'
|
|
96
|
-
type: :development
|
|
97
|
-
prerelease: false
|
|
98
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
99
|
-
requirements:
|
|
100
|
-
- - ">="
|
|
101
|
-
- !ruby/object:Gem::Version
|
|
102
|
-
version: '0'
|
|
103
|
-
- !ruby/object:Gem::Dependency
|
|
104
|
-
name: shrine
|
|
89
|
+
name: rack-test
|
|
105
90
|
requirement: !ruby/object:Gem::Requirement
|
|
106
91
|
requirements:
|
|
107
92
|
- - "~>"
|
|
108
93
|
- !ruby/object:Gem::Version
|
|
109
|
-
version: '2.
|
|
94
|
+
version: '2.0'
|
|
110
95
|
type: :development
|
|
111
96
|
prerelease: false
|
|
112
97
|
version_requirements: !ruby/object:Gem::Requirement
|
|
113
98
|
requirements:
|
|
114
99
|
- - "~>"
|
|
115
100
|
- !ruby/object:Gem::Version
|
|
116
|
-
version: '2.
|
|
101
|
+
version: '2.0'
|
|
117
102
|
- !ruby/object:Gem::Dependency
|
|
118
|
-
name: shrine
|
|
119
|
-
requirement: !ruby/object:Gem::Requirement
|
|
120
|
-
requirements:
|
|
121
|
-
- - ">="
|
|
122
|
-
- !ruby/object:Gem::Version
|
|
123
|
-
version: '0'
|
|
124
|
-
type: :development
|
|
125
|
-
prerelease: false
|
|
126
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
127
|
-
requirements:
|
|
128
|
-
- - ">="
|
|
129
|
-
- !ruby/object:Gem::Version
|
|
130
|
-
version: '0'
|
|
131
|
-
- !ruby/object:Gem::Dependency
|
|
132
|
-
name: aws-sdk-core
|
|
103
|
+
name: shrine
|
|
133
104
|
requirement: !ruby/object:Gem::Requirement
|
|
134
105
|
requirements:
|
|
135
106
|
- - "~>"
|
|
136
107
|
- !ruby/object:Gem::Version
|
|
137
|
-
version: '3.
|
|
108
|
+
version: '3.0'
|
|
138
109
|
type: :development
|
|
139
110
|
prerelease: false
|
|
140
111
|
version_requirements: !ruby/object:Gem::Requirement
|
|
141
112
|
requirements:
|
|
142
113
|
- - "~>"
|
|
143
114
|
- !ruby/object:Gem::Version
|
|
144
|
-
version: '3.
|
|
115
|
+
version: '3.0'
|
|
145
116
|
- !ruby/object:Gem::Dependency
|
|
146
117
|
name: rexml
|
|
147
118
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -156,7 +127,6 @@ dependencies:
|
|
|
156
127
|
- - ">="
|
|
157
128
|
- !ruby/object:Gem::Version
|
|
158
129
|
version: '0'
|
|
159
|
-
description:
|
|
160
130
|
email:
|
|
161
131
|
- janko.marohnic@gmail.com
|
|
162
132
|
executables: []
|
|
@@ -175,7 +145,6 @@ homepage: https://github.com/janko/uppy-s3_multipart
|
|
|
175
145
|
licenses:
|
|
176
146
|
- MIT
|
|
177
147
|
metadata: {}
|
|
178
|
-
post_install_message:
|
|
179
148
|
rdoc_options: []
|
|
180
149
|
require_paths:
|
|
181
150
|
- lib
|
|
@@ -183,15 +152,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
183
152
|
requirements:
|
|
184
153
|
- - ">="
|
|
185
154
|
- !ruby/object:Gem::Version
|
|
186
|
-
version: '2.
|
|
155
|
+
version: '2.6'
|
|
187
156
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
188
157
|
requirements:
|
|
189
158
|
- - ">="
|
|
190
159
|
- !ruby/object:Gem::Version
|
|
191
160
|
version: '0'
|
|
192
161
|
requirements: []
|
|
193
|
-
rubygems_version:
|
|
194
|
-
signing_key:
|
|
162
|
+
rubygems_version: 4.0.13
|
|
195
163
|
specification_version: 4
|
|
196
164
|
summary: Provides a Rack application that implements endpoints for the AwsS3Multipart
|
|
197
165
|
Uppy plugin.
|