Compare commits
8 Commits
Author | SHA1 | Date |
---|---|---|
dependabot[bot] | 51a953b7ad | |
dependabot[bot] | 14bff45d21 | |
dependabot[bot] | 8f3644f9ba | |
Ambrose Chua | 0d78f1dc33 | |
Ambrose Chua | b5dacbc9bf | |
Ambrose Chua | 927fb90f44 | |
Ambrose Chua | 8c3a91b0a8 | |
Ambrose Chua | 967b469d65 |
|
@ -21,7 +21,7 @@ jobs:
|
||||||
- name: Set up Go 1.x
|
- name: Set up Go 1.x
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: ^1.16
|
go-version: ^1.17
|
||||||
|
|
||||||
- name: Check out code into the Go module directory
|
- name: Check out code into the Go module directory
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
@ -42,7 +42,7 @@ jobs:
|
||||||
- name: Set up Go 1.x
|
- name: Set up Go 1.x
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: ^1.16
|
go-version: ^1.17
|
||||||
|
|
||||||
- name: Check out code into the Go module directory
|
- name: Check out code into the Go module directory
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
@ -63,7 +63,7 @@ jobs:
|
||||||
- name: Set up Go 1.x
|
- name: Set up Go 1.x
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: ^1.16
|
go-version: ^1.17
|
||||||
|
|
||||||
- name: Check out code into the Go module directory
|
- name: Check out code into the Go module directory
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
@ -80,7 +80,7 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
git add .
|
git add .
|
||||||
if output=$(git status --porcelain) && [ ! -z "$output" ]; then
|
if output=$(git status --porcelain) && [ ! -z "$output" ]; then
|
||||||
git commit -m "[Action] go fmt" -a
|
git commit -m 'style: `go fmt`' -a
|
||||||
git push
|
git push
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ jobs:
|
||||||
- name: Set up Go 1.x
|
- name: Set up Go 1.x
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: ^1.16
|
go-version: ^1.17
|
||||||
|
|
||||||
- name: Check out code into the Go module directory
|
- name: Check out code into the Go module directory
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
|
@ -36,6 +36,11 @@ jobs:
|
||||||
uses: docker/metadata-action@v3
|
uses: docker/metadata-action@v3
|
||||||
with:
|
with:
|
||||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
|
tags: |
|
||||||
|
type=ref,event=branch
|
||||||
|
type=ref,event=pr
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
id: meta
|
id: meta
|
||||||
|
|
||||||
- name: Build and push Docker images
|
- name: Build and push Docker images
|
||||||
|
|
|
@ -7,7 +7,7 @@ RUN cd web && npm install
|
||||||
ARG NODE_ENV=production
|
ARG NODE_ENV=production
|
||||||
RUN cd web && npm run build
|
RUN cd web && npm run build
|
||||||
|
|
||||||
FROM golang:1.16-alpine3.14 as build
|
FROM golang:1.17-alpine3.14 as build
|
||||||
|
|
||||||
RUN apk add \
|
RUN apk add \
|
||||||
make
|
make
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2021 Ambrose Chua
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
|
@ -131,6 +131,61 @@ func handleGetUploadedParts(w http.ResponseWriter, req *http.Request) {
|
||||||
encoder.Encode(getUploadedPartsRes(parts))
|
encoder.Encode(getUploadedPartsRes(parts))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* batchSignPartsUpload */
|
||||||
|
|
||||||
|
type batchSignPartsUploadRes struct {
|
||||||
|
PresignedURLs map[string]string `json:"presignedUrls"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func handleBatchSignPartsUpload(w http.ResponseWriter, req *http.Request) {
|
||||||
|
vars := mux.Vars(req)
|
||||||
|
cred, err := getCredential(vars["id"])
|
||||||
|
if err != nil {
|
||||||
|
errorResponse(w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
uploadID := vars["uploadID"]
|
||||||
|
key := req.URL.Query().Get("key")
|
||||||
|
partNumbers := req.URL.Query().Get("partNumbers")
|
||||||
|
|
||||||
|
if uploadID == "" || key == "" || partNumbers == "" {
|
||||||
|
errorResponse(w, req, fmt.Errorf("%w", errBadRequest))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
partNumbersArray := strings.Split(partNumbers, ",")
|
||||||
|
partNumbersParsed := make([]uint16, 0, len(partNumbersArray))
|
||||||
|
for _, partNumber := range partNumbersArray {
|
||||||
|
n, err := strconv.ParseUint(partNumber, 10, 16)
|
||||||
|
if n < 1 || n > 10000 || err != nil {
|
||||||
|
errorResponse(w, req, fmt.Errorf("%w: invalid part number", errBadRequest))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
partNumbersParsed = append(partNumbersParsed, uint16(n))
|
||||||
|
}
|
||||||
|
|
||||||
|
presignedURLs := make(map[string]string, len(partNumbersParsed))
|
||||||
|
for _, partNumber := range partNumbersParsed {
|
||||||
|
params := make(url.Values)
|
||||||
|
params.Add("partNumber", strconv.FormatUint(uint64(partNumber), 10))
|
||||||
|
params.Add("uploadId", uploadID)
|
||||||
|
unsignedReq, err := http.NewRequest(http.MethodPut, cred.Endpoint+"/"+key+"?"+params.Encode(), nil)
|
||||||
|
if err != nil {
|
||||||
|
errorResponse(w, req, fmt.Errorf("%w: %s", errInternalServerError, err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
signedReq := preSign(unsignedReq, cred)
|
||||||
|
presignedURLs[strconv.FormatUint(uint64(partNumber), 10)] = signedReq.URL.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
encoder := json.NewEncoder(w)
|
||||||
|
encoder.Encode(batchSignPartsUploadRes{
|
||||||
|
PresignedURLs: presignedURLs,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/* signPartUpload */
|
/* signPartUpload */
|
||||||
|
|
||||||
type signPartUploadRes struct {
|
type signPartUploadRes struct {
|
||||||
|
|
1
main.go
1
main.go
|
@ -38,6 +38,7 @@ func main() {
|
||||||
|
|
||||||
s3Router.Methods(http.MethodPost).Path("").HandlerFunc(handleCreateMultipartUpload)
|
s3Router.Methods(http.MethodPost).Path("").HandlerFunc(handleCreateMultipartUpload)
|
||||||
s3Router.Methods(http.MethodGet).Path("/{uploadID}").HandlerFunc(handleGetUploadedParts)
|
s3Router.Methods(http.MethodGet).Path("/{uploadID}").HandlerFunc(handleGetUploadedParts)
|
||||||
|
s3Router.Methods(http.MethodGet).Path("/{uploadID}/batch").HandlerFunc(handleBatchSignPartsUpload)
|
||||||
s3Router.Methods(http.MethodGet).Path("/{uploadID}/{uploadPart}").HandlerFunc(handleSignPartUpload)
|
s3Router.Methods(http.MethodGet).Path("/{uploadID}/{uploadPart}").HandlerFunc(handleSignPartUpload)
|
||||||
s3Router.Methods(http.MethodPost).Path("/{uploadID}/complete").HandlerFunc(handleCompleteMultipartUpload)
|
s3Router.Methods(http.MethodPost).Path("/{uploadID}/complete").HandlerFunc(handleCompleteMultipartUpload)
|
||||||
s3Router.Methods(http.MethodDelete).Path("/{uploadID}").HandlerFunc(handleAbortMultipartUpload)
|
s3Router.Methods(http.MethodDelete).Path("/{uploadID}").HandlerFunc(handleAbortMultipartUpload)
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -8,18 +8,18 @@
|
||||||
"watch": "rollup --config --watch"
|
"watch": "rollup --config --watch"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@rollup/plugin-commonjs": "^19.0.0",
|
"@rollup/plugin-commonjs": "^21.0.1",
|
||||||
"@rollup/plugin-node-resolve": "^13.0.0",
|
"@rollup/plugin-node-resolve": "^13.1.3",
|
||||||
"@tailwindcss/forms": "^0.3.2",
|
"@tailwindcss/forms": "^0.4.0",
|
||||||
"@uppy/aws-s3-multipart": "^1.8.15",
|
"@uppy/aws-s3-multipart": "^2.2.0",
|
||||||
"@uppy/core": "^1.18.1",
|
"@uppy/core": "^2.1.5",
|
||||||
"@uppy/drag-drop": "^1.4.27",
|
"@uppy/drag-drop": "^2.0.6",
|
||||||
"@uppy/status-bar": "^1.9.3",
|
"@uppy/status-bar": "^2.1.2",
|
||||||
"filesize": "^6.3.0",
|
"filesize": "^8.0.7",
|
||||||
"rollup": "^2.48.0",
|
"rollup": "^2.67.2",
|
||||||
"rollup-plugin-copy": "^3.4.0",
|
"rollup-plugin-copy": "^3.4.0",
|
||||||
"rollup-plugin-postcss": "^4.0.0",
|
"rollup-plugin-postcss": "^4.0.2",
|
||||||
"rollup-plugin-terser": "^7.0.2",
|
"rollup-plugin-terser": "^7.0.2",
|
||||||
"tailwindcss": "^2.1.2"
|
"tailwindcss": "^3.0.22"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,12 @@ uploadAreas.forEach(uploadArea => {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Uppy */
|
/* Uppy */
|
||||||
|
|
||||||
|
let limit = window.localStorage.getItem('parallel');
|
||||||
|
if (!limit) {
|
||||||
|
limit = 3;
|
||||||
|
}
|
||||||
|
window.localStorage.setItem('parallel', 3);
|
||||||
|
|
||||||
const uppy = new Uppy({
|
const uppy = new Uppy({
|
||||||
autoProceed: true,
|
autoProceed: true,
|
||||||
|
@ -54,7 +60,7 @@ uploadAreas.forEach(uploadArea => {
|
||||||
showProgressDetails: true,
|
showProgressDetails: true,
|
||||||
});
|
});
|
||||||
uppy.use(AwsS3Multipart, {
|
uppy.use(AwsS3Multipart, {
|
||||||
limit: 3,
|
limit,
|
||||||
companionUrl: window.location.pathname,
|
companionUrl: window.location.pathname,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
purge: [
|
content: [
|
||||||
'./*.tmpl',
|
'./*.tmpl',
|
||||||
'./src/*.js',
|
'./src/*.js',
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in New Issue