mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 22:00:31 +00:00
feat: add s3 env variables to .env.example
This commit is contained in:
@@ -1,23 +1,19 @@
|
||||
import { Service } from 'typedi';
|
||||
import { GetObjectCommand } from '@aws-sdk/client-s3';
|
||||
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
|
||||
import { s3 } from '@/lib/S3/S3';
|
||||
import { Service } from 'typedi';
|
||||
import config from '@/config';
|
||||
|
||||
@Service()
|
||||
export class getAttachmentPresignedUrl {
|
||||
/**
|
||||
* Retrieves the presigned url of the given attachment key.
|
||||
* @param {string} key
|
||||
* @param {string} key
|
||||
* @returns {Promise<string?>}
|
||||
*/
|
||||
async getPresignedUrl(key: string) {
|
||||
const params = {
|
||||
Bucket: process.env.AWS_BUCKET,
|
||||
Key: key,
|
||||
Expires: 60 * 5, // 5 minutes
|
||||
};
|
||||
const command = new GetObjectCommand({
|
||||
Bucket: process.env.AWS_BUCKET,
|
||||
Bucket: config.s3.bucket,
|
||||
Key: key,
|
||||
});
|
||||
const signedUrl = await getSignedUrl(s3, command, { expiresIn: 300 });
|
||||
|
||||
Reference in New Issue
Block a user