Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S3 upload custom endpoint url #244

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion template/app/.env.server.example
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ GOOGLE_ANALYTICS_PRIVATE_KEY=LS02...
GOOGLE_ANALYTICS_PROPERTY_ID=123456789

# (OPTIONAL) get your aws s3 credentials at https://console.aws.amazon.com and create a new IAM user with S3 access
AWS_S3_ENDPOINT_URL=https://...
AWS_S3_IAM_ACCESS_KEY=ACK...
AWS_S3_IAM_SECRET_KEY=t+33a...
AWS_S3_FILES_BUCKET=your-bucket-name
AWS_S3_REGION=your-region
AWS_S3_REGION=your-region
3 changes: 2 additions & 1 deletion template/app/src/file-upload/s3Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { GetObjectCommand, PutObjectCommand } from '@aws-sdk/client-s3';
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';

const s3Client = new S3Client({
endpoint: process.env.AWS_S3_ENDPOINT_URL,
region: process.env.AWS_S3_REGION,
credentials: {
accessKeyId: process.env.AWS_S3_IAM_ACCESS_KEY!,
Expand Down Expand Up @@ -36,4 +37,4 @@ export const getDownloadFileSignedURLFromS3 = async ({ key }: { key: string }) =
};
const command = new GetObjectCommand(s3Params);
return await getSignedUrl(s3Client, command, { expiresIn: 3600 });
}
}