Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uppy-s3_multipart
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
uppy-s3_multipart
Commits
7767403c
Unverified
Commit
7767403c
authored
Sep 14, 2021
by
Adrien S
Committed by
GitHub
Sep 14, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for batch part presigning (#24)
This endpoint is now used in Uppy 2.x.
parent
221e1a3d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
0 deletions
+69
-0
app.rb
lib/uppy/s3_multipart/app.rb
+13
-0
app_test.rb
test/app_test.rb
+56
-0
No files found.
lib/uppy/s3_multipart/app.rb
View file @
7767403c
...
...
@@ -75,6 +75,19 @@ module Uppy
end
end
# GET /s3/multipart/:uploadId/batch
r
.
get
String
,
"batch"
do
|
upload_id
|
key
=
param!
(
"key"
)
part_numbers
=
param!
(
"partNumbers"
).
split
(
","
)
batch
=
part_numbers
.
map
do
|
part_number
|
result
=
client_call
(
:prepare_upload_part
,
upload_id:
upload_id
,
key:
key
,
part_number:
part_number
)
[
part_number
,
result
.
fetch
(
:url
)]
end
.
to_h
{
presignedUrls:
batch
}
end
# GET /s3/multipart/:uploadId/:partNumber
r
.
get
String
,
String
do
|
upload_id
,
part_number
|
key
=
param!
(
"key"
)
...
...
test/app_test.rb
View file @
7767403c
...
...
@@ -187,6 +187,62 @@ describe Uppy::S3Multipart::App do
end
end
describe
"GET /s3/multipart/:uploadId/batch"
do
it
"returns presigned urls for batch part upload"
do
response
=
app
.
get
"/s3/multipart/foo/batch"
,
query:
{
key:
"bar"
,
partNumbers:
"1,2"
}
assert_equal
200
,
response
.
status
assert_equal
"application/json"
,
response
.
headers
[
"Content-Type"
]
assert_match
URI
.
regexp
,
response
.
body_json
[
"presignedUrls"
][
"1"
]
assert_match
URI
.
regexp
,
response
.
body_json
[
"presignedUrls"
][
"2"
]
end
it
"returns error response when 'key' parameter is missing"
do
response
=
app
.
get
"/s3/multipart/foo/batch"
,
query:
{
partNumbers:
"1,2"
}
assert_equal
400
,
response
.
status
assert_equal
"application/json"
,
response
.
headers
[
"Content-Type"
]
assert_equal
"Missing
\"
key
\"
parameter"
,
response
.
body_json
[
"error"
]
end
it
"returns error response when 'partNumbers' parameter is missing"
do
response
=
app
.
get
"/s3/multipart/foo/batch"
,
query:
{
key:
"bar"
}
assert_equal
400
,
response
.
status
assert_equal
"application/json"
,
response
.
headers
[
"Content-Type"
]
assert_equal
"Missing
\"
partNumbers
\"
parameter"
,
response
.
body_json
[
"error"
]
end
it
"handles :options as a hash"
do
@endpoint
=
Uppy
::
S3Multipart
::
App
.
new
(
bucket:
@bucket
,
options:
{
prepare_upload_part:
{
expires_in:
10
}
})
response
=
app
.
get
"/s3/multipart/foo/batch"
,
query:
{
key:
"bar"
,
partNumbers:
"1,2"
}
assert_match
"X-Amz-Expires=10"
,
response
.
body_json
[
"presignedUrls"
][
"1"
]
assert_match
"X-Amz-Expires=10"
,
response
.
body_json
[
"presignedUrls"
][
"2"
]
end
it
"handles :options as a block"
do
@endpoint
=
Uppy
::
S3Multipart
::
App
.
new
(
bucket:
@bucket
,
options:
{
prepare_upload_part:
->
(
request
)
{
assert_kind_of
Rack
::
Request
,
request
{
expires_in:
10
}
}
})
response
=
app
.
get
"/s3/multipart/foo/batch"
,
query:
{
key:
"bar"
,
partNumbers:
"1,2"
}
assert_match
"X-Amz-Expires=10"
,
response
.
body_json
[
"presignedUrls"
][
"1"
]
assert_match
"X-Amz-Expires=10"
,
response
.
body_json
[
"presignedUrls"
][
"2"
]
end
end
describe
"GET /s3/multipart/:uploadId/:partNumber"
do
it
"returns presigned url for part upload"
do
response
=
app
.
get
"/s3/multipart/foo/1"
,
query:
{
key:
"bar"
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment