mirror of
https://github.com/filecoffee/filehost.git
synced 2024-11-13 19:49:56 +01:00
adding s3 endpoint url
This commit is contained in:
parent
c0fb7f8569
commit
be25ea36f2
3 changed files with 10 additions and 1 deletions
|
@ -10,6 +10,7 @@ AWS_ACCESS_KEY_ID=your_aws_access_key_id
|
|||
AWS_SECRET_ACCESS_KEY=your_aws_secret_access_key
|
||||
AWS_REGION=your_aws_region
|
||||
S3_BUCKET_NAME=your_s3_bucket_name
|
||||
S3_ENDPOINT=your_s3_endpoint
|
||||
|
||||
# If you are using local storage, this is the path where the files will be uploaded
|
||||
LOCAL_UPLOAD_PATH=uploads
|
||||
|
|
|
@ -24,6 +24,7 @@ if (storageMode === "local") {
|
|||
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
||||
region: process.env.AWS_REGION,
|
||||
bucketName: process.env.S3_BUCKET_NAME,
|
||||
endpoint: process.env.S3_ENDPOINT,
|
||||
};
|
||||
storageEngine = initializeS3Storage(multerOptions, fileNameLength, s3Config);
|
||||
} else {
|
||||
|
|
|
@ -4,7 +4,14 @@ const AWS = require("aws-sdk");
|
|||
const { nanoid } = require("nanoid");
|
||||
|
||||
const initializeS3Storage = (multerOptions, fileNameLength, s3Config) => {
|
||||
const s3 = new AWS.S3(s3Config);
|
||||
const s3 = new AWS.S3({
|
||||
accessKeyId: s3Config.accessKeyId,
|
||||
secretAccessKey: s3Config.secretAccessKey,
|
||||
endpoint: s3Config.endpoint,
|
||||
s3ForcePathStyle: true,
|
||||
signatureVersion: "v4",
|
||||
});
|
||||
|
||||
const storage = multer.memoryStorage();
|
||||
const upload = multer({ storage: storage, ...multerOptions });
|
||||
|
||||
|
|
Loading…
Reference in a new issue