“Multer S3 Access verweigert” Code-Antworten

Multer S3 Access verweigert

	static awsStorage: multer.StorageEngine = multerS3({
		s3: new aws.S3({
			credentials: new aws.Credentials({
				accessKeyId: process.env.AWS_ACCESS_KEY_ID,
				secretAccessKey: process.env.AWS_ACCESS_KEY
			}),
			hostPrefixEnabled: true,
			computeChecksums: true,
			s3BucketEndpoint: true,
			correctClockSkew: true
		}),
		bucket: process.env.AWS_BUCKET_NAME,
		contentType: multerS3.AUTO_CONTENT_TYPE,
		serverSideEncryption: 'AES256',
		[Multer.acl as any]: 'public-read',
		metadata(_req: Request, file: Express.Multer.File, done: any) {
			if (!file) done(new Error('Get file upload failed'), null)
			done(null, file)
		},
		key(_req: Request, file: Express.Multer.File, done: any) {
			done(null, `${Date.now()}.${file.originalname.split('.')[1]}`)
		}
	})
Restu Wahyu Saputra

Verwenden von Multer -S3 Amazon Server Bild -Upload -Fehlerzugriff Abgelehnt

// or use my trick like this
let acl = 'ACL'

// like this not my trick
var upload = multer({
    storage: multerS3({
        s3: s3,
        ACL: 'public-read',
        bucket: BucketName,
        key: function (req, file, cb) {
            cb(null, new Date().toISOString() + '-' + file.originalname);
        }
    })
});

// like this with my trick for by error in ts
var upload = multer({
    storage: multerS3({
        s3: s3,
        [acl]: 'public-read',
        bucket: BucketName,
        key: function (req, file, cb) {
            cb(null, new Date().toISOString() + '-' + file.originalname);
        }
    })
});
Restu Wahyu Saputra

Ähnliche Antworten wie “Multer S3 Access verweigert”

Fragen ähnlich wie “Multer S3 Access verweigert”

Weitere verwandte Antworten zu “Multer S3 Access verweigert” auf TypeScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen