Skip to content

Commit

Permalink
Calculate url based of bucket, region, and key (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanto authored Oct 26, 2022
1 parent 540af7c commit 6c24a1d
Show file tree
Hide file tree
Showing 6 changed files with 2,486 additions and 2,336 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.log
.vscode
.DS_Store
node_modules
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"workspaces": ["packages/next-s3-upload", "packages/docs-site"],
"scripts": {
"dev": "yarn workspace next-s3-upload start",
"build": "yarn workspace next-s3-upload build",
"docs": "yarn workspace docs-site dev",
"test": "yarn workspace docs-site cypress run"
}
Expand Down
8 changes: 7 additions & 1 deletion packages/docs-site/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
"extends": ["next", "next/core-web-vitals"],
"rules": {
"jsx-a11y/alt-text": "off",
"@next/next/no-img-element": "off"
"@next/next/no-img-element": "off",
"react/no-unknown-property": [
2,
{
"ignore": ["jsx"]
}
]
}
}
3 changes: 2 additions & 1 deletion packages/docs-site/cypress.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"baseUrl": "http://localhost:3000"
"baseUrl": "http://localhost:3000",
"defaultCommandTimeout": 10000
}
7 changes: 6 additions & 1 deletion packages/next-s3-upload/src/hooks/use-s3-upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,13 @@ export const useS3Upload: UseS3Upload = (options = {}) => {

let uploadResult = (await s3Upload.done()) as CompleteMultipartUploadCommandOutput;

let url =
uploadResult.Bucket && uploadResult.Key
? `https://${uploadResult.Bucket}.s3.${data.region}.amazonaws.com/${uploadResult.Key}`
: '';

return {
url: uploadResult.Location ?? '',
url,
bucket: uploadResult.Bucket ?? '',
key: uploadResult.Key ?? '',
};
Expand Down
Loading

1 comment on commit 6c24a1d

@vercel
Copy link

@vercel vercel bot commented on 6c24a1d Oct 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.