General
How to use environment variables?
- Create an environment variable and copy the environment variable key name
- Utilize the process environment variable
process.env.<KEYNAME>
, as shown below
In the code sample, S3_BUCKET, S3_REGION, S3_ACCESS_KEY_ID, and S3_SECRET_ACCESS_KEY are all environment variables.
import { uploadFileToS3 } from "@intuned/sdk/files";
export async function uploadFile(file: Parameters<typeof uploadFileToS3>[0], fileName?: string) {
return await uploadFileToS3(file, {
fileNameOverride: fileName, s3Configs: {
bucket: process.env.S3_BUCKET,
region: process.env.S3_REGION,
accessKeyId: process.env.S3_ACCESS_KEY_ID,
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
}
});
}