Skip to content

Commit

Permalink
use env vars to use different storage services (#39)
Browse files Browse the repository at this point in the history
* use env vars to use different storage services

* default other variables
  • Loading branch information
ephraimduncan authored Feb 16, 2024
1 parent 7f18a97 commit 9fc4fc3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions client/.env
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@ SCHOOL=knust
COOKIE_SECRET=secret1,secret2
SECRET_KEY=secret1
RESEND_API_KEY=
AWS_UPLOAD_ENDPOINT="eu-central-1.linodeobjects.com"
AWS_REGION="eu-central-1"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_BUCKET=compa
6 changes: 3 additions & 3 deletions client/app/lib/s3.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Upload } from "@aws-sdk/lib-storage";
import aws from "aws-sdk";
import { Readable } from "stream";

const endpoint = new aws.Endpoint("eu-central-1.linodeobjects.com");
const endpoint = new aws.Endpoint(process.env.AWS_UPLOAD_ENDPOINT);

// @ts-ignore
const s3 = new S3Client({
Expand All @@ -12,7 +12,7 @@ const s3 = new S3Client({
accessKeyId: process.env.AWS_ACCESS_KEY_ID as string,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY as string,
},
region: "eu-central-1",
region: process.env.AWS_REGION as string,
});

async function upload(
Expand All @@ -25,7 +25,7 @@ async function upload(
leavePartsOnError: false,
params: {
ACL: "public-read",
Bucket: "compa",
Bucket: process.env.AWS_BUCKET as string,
Key: filename,
ContentType: contentType,
CacheControl: "max-age=31536000",
Expand Down

0 comments on commit 9fc4fc3

Please sign in to comment.