Skip to content

Commit

Permalink
fix: s3 client (#611)
Browse files Browse the repository at this point in the history
  • Loading branch information
danadajian authored Jan 23, 2025
1 parent 3c67569 commit 2b3bbd1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
12 changes: 6 additions & 6 deletions app/backend/src/getTemporaryObjectUrl.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { s3 } from 'bun';
import { S3Client } from './s3Client';
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
import { GetObjectCommand } from '@aws-sdk/client-s3';

export const getTemporaryObjectUrl = async (
filePath: string,
bucket: string
) => {
return s3.file(filePath, { bucket }).presign({ expiresIn: oneHour });
export const getTemporaryObjectUrl = async (key: string, bucket: string) => {
const command = new GetObjectCommand({ Bucket: bucket, Key: key });
return getSignedUrl(S3Client, command, { expiresIn: oneHour });
};

const oneHour = 3600;
2 changes: 1 addition & 1 deletion app/backend/src/s3Client.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { S3 } from '@aws-sdk/client-s3';

export const S3Client = new S3({ region: 'us-west-2' });
export const S3Client = new S3();
1 change: 1 addition & 0 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"private": true,
"dependencies": {
"@aws-sdk/client-s3": "3.717.0",
"@aws-sdk/s3-request-presigner": "3.717.0",
"@headlessui/react": "2.2.0",
"@octokit/rest": "20.1.1",
"@tanstack/react-query": "5.62.11",
Expand Down
5 changes: 5 additions & 0 deletions bun.lock
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"name": "app",
"dependencies": {
"@aws-sdk/client-s3": "3.717.0",
"@aws-sdk/s3-request-presigner": "3.717.0",
"@headlessui/react": "2.2.0",
"@octokit/rest": "20.1.1",
"@tanstack/react-query": "5.62.11",
Expand Down Expand Up @@ -214,6 +215,8 @@

"@aws-sdk/region-config-resolver": ["@aws-sdk/[email protected]", "", { "dependencies": { "@aws-sdk/types": "3.714.0", "@smithy/node-config-provider": "^3.1.12", "@smithy/types": "^3.7.2", "@smithy/util-config-provider": "^3.0.0", "@smithy/util-middleware": "^3.0.11", "tslib": "^2.6.2" } }, "sha512-HJzsQxgMOAzZrbf/YIqEx30or4tZK1oNAk6Wm6xecUQx+23JXIaePRu1YFUOLBBERQ4QBPpISFurZWBMZ5ibAw=="],

"@aws-sdk/s3-request-presigner": ["@aws-sdk/[email protected]", "", { "dependencies": { "@aws-sdk/signature-v4-multi-region": "3.716.0", "@aws-sdk/types": "3.714.0", "@aws-sdk/util-format-url": "3.714.0", "@smithy/middleware-endpoint": "^3.2.6", "@smithy/protocol-http": "^4.1.8", "@smithy/smithy-client": "^3.5.1", "@smithy/types": "^3.7.2", "tslib": "^2.6.2" } }, "sha512-gpT310jVQiqVxE6Nh4yEABbYNVOfUC/DuMtp5/JAb+cz1nNLfA45KgaJ73UCPbimVszUH0Cb7RouC/zv1uB84w=="],

"@aws-sdk/signature-v4-multi-region": ["@aws-sdk/[email protected]", "", { "dependencies": { "@aws-sdk/middleware-sdk-s3": "3.716.0", "@aws-sdk/types": "3.714.0", "@smithy/protocol-http": "^4.1.8", "@smithy/signature-v4": "^4.2.4", "@smithy/types": "^3.7.2", "tslib": "^2.6.2" } }, "sha512-k0goWotZKKz+kV6Ln0qeAMSeSVi4NipuIIz5R8A0uCF2zBK4CXWdZR7KeaIoLBhJwQnHj1UU7E+2MK74KIUBzA=="],

"@aws-sdk/token-providers": ["@aws-sdk/[email protected]", "", { "dependencies": { "@aws-sdk/types": "3.714.0", "@smithy/property-provider": "^3.1.11", "@smithy/shared-ini-file-loader": "^3.1.12", "@smithy/types": "^3.7.2", "tslib": "^2.6.2" }, "peerDependencies": { "@aws-sdk/client-sso-oidc": "^3.714.0" } }, "sha512-vKN064aLE3kl+Zl16Ony3jltHnMddMBT7JRkP1L+lLywhA0PcAKxpdvComul/sTBWnbnwLnaS5NsDUhcWySH8A=="],
Expand All @@ -224,6 +227,8 @@

"@aws-sdk/util-endpoints": ["@aws-sdk/[email protected]", "", { "dependencies": { "@aws-sdk/types": "3.714.0", "@smithy/types": "^3.7.2", "@smithy/util-endpoints": "^2.1.7", "tslib": "^2.6.2" } }, "sha512-Xv+Z2lhe7w7ZZRsgBwBMZgGTVmS+dkkj2S13uNHAx9lhB5ovM8PhK5G/j28xYf6vIibeuHkRAbb7/ozdZIGR+A=="],

"@aws-sdk/util-format-url": ["@aws-sdk/[email protected]", "", { "dependencies": { "@aws-sdk/types": "3.714.0", "@smithy/querystring-builder": "^3.0.11", "@smithy/types": "^3.7.2", "tslib": "^2.6.2" } }, "sha512-PA/ES6BeKmYzFOsZ3az/8MqSLf6uzXAS7GsYONZMF6YASn4ewd/AspuvQMp6+x9VreAPCq7PecF+XL9KXejtPg=="],

"@aws-sdk/util-locate-window": ["@aws-sdk/[email protected]", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-Yf2CS10BqK688DRsrKI/EO6B8ff5J86NXe4C+VCysK7UOgN0l1zOTeTukZ3H8Q9tYYX3oaF1961o8vRkFm7Nmw=="],

"@aws-sdk/util-user-agent-browser": ["@aws-sdk/[email protected]", "", { "dependencies": { "@aws-sdk/types": "3.714.0", "@smithy/types": "^3.7.2", "bowser": "^2.11.0", "tslib": "^2.6.2" } }, "sha512-OdJJ03cP9/MgIVToPJPCPUImbpZzTcwdIgbXC0tUQPJhbD7b7cB4LdnkhNHko+MptpOrCq4CPY/33EpOjRdofw=="],
Expand Down

0 comments on commit 2b3bbd1

Please sign in to comment.