-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
16 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export download from './download'; | ||
export S3Up from './S3Up'; | ||
export signUpload from './signUpload'; | ||
export upload from './upload'; | ||
export { default as download } from './download'; | ||
export { default as S3Up } from './S3Up'; | ||
export { default as signUpload } from './signUpload'; | ||
export { default as upload } from './upload'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,14 @@ | ||
import { createPresignedPost } from '@aws-sdk/s3-presigned-post'; | ||
|
||
export default function signUpload(props, client) { | ||
if (!props?.key) throw new Error(`key is required at signUpload({ key: ${props?.key} })`); | ||
if (!props?.bucket) throw new Error(`bucket is required at signUpload({ bucket: ${props?.bucket} })`); | ||
|
||
return new Promise((resolve, reject) => client.createPresignedPost({ | ||
return createPresignedPost(client, { | ||
Bucket: props.bucket, | ||
Key: props.key, | ||
Expires: props.expires || 3600, | ||
Conditions: props.conditions, | ||
Fields: { | ||
key: props.key, | ||
...props.fields, | ||
}, | ||
}, (err, res) => { | ||
if (err) return reject(err); | ||
return resolve(res); | ||
})); | ||
Fields: props.fields, | ||
}); | ||
} |