[FEATURE] Basic System with file manager (#4)
Co-authored-by: dunemask <dunemask@gmail.com> Co-authored-by: Dunemask <dunemask@gmail.com> Reviewed-on: https://gitea.dunemask.dev/elysium/minecluster/pulls/4
This commit is contained in:
parent
8fb5b34c77
commit
4f19cf19d9
62 changed files with 5910 additions and 1190 deletions
34
lib/storage/s3-integration.js
Normal file
34
lib/storage/s3-integration.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
import multer from "multer";
|
||||
import multerS3 from "multer-s3";
|
||||
import AWS from "aws-sdk";
|
||||
|
||||
// Environment Variables
|
||||
const {
|
||||
MCL_S3_ENDPOINT: s3Endpoint,
|
||||
MCL_S3_ACCESS_KEY_ID: s3KeyId,
|
||||
MCL_S3_ACCESS_KEY: s3Key,
|
||||
} = process.env;
|
||||
|
||||
export const mcl = "mcl";
|
||||
|
||||
export const s3 = new AWS.S3({
|
||||
endpoint: s3Endpoint,
|
||||
accessKeyId: s3KeyId,
|
||||
secretAccessKey: s3Key,
|
||||
sslEnabled: true,
|
||||
s3ForcePathStyle: true,
|
||||
});
|
||||
|
||||
const storage = multerS3({
|
||||
s3,
|
||||
bucket,
|
||||
contentType: multerS3.AUTO_CONTENT_TYPE,
|
||||
metadata: (req, file, cb) => {
|
||||
cb(null, { fieldName: file.fieldname });
|
||||
},
|
||||
key: (req, file, cb) => {
|
||||
cb(null, Date.now().toString());
|
||||
},
|
||||
});
|
||||
|
||||
export const upload = multer({ storage });
|
Loading…
Add table
Add a link
Reference in a new issue