Store images and other assets in AWS S3
Integration type
Category
Repository
Package
Last published
Downloads in past month
The AssetServerPlugin is part of a standard Vendure installation, but if it is not already installed, you must install it:
npm install @vendure/asset-server-plugin
Before using this strategy, make sure you have the @aws-sdk/client-s3
and @aws-sdk/lib-storage
package installed:
npm install @aws-sdk/client-s3 @aws-sdk/lib-storage
import { AssetServerPlugin, configureS3AssetStorage } from '@vendure/asset-server-plugin';
import { DefaultAssetNamingStrategy } from '@vendure/core';
import { fromEnv } from '@aws-sdk/credential-providers';
// ...
plugins: [
AssetServerPlugin.init({
route: 'assets',
assetUploadDir: path.join(__dirname, 'assets'),
namingStrategy: new DefaultAssetNamingStrategy(),
storageStrategyFactory: configureS3AssetStorage({
bucket: 'my-s3-bucket',
credentials: fromEnv(), // or any other credential provider
nativeS3Configuration: {
region: process.env.AWS_REGION,
},
}),
}),
See the S3AssetStorageStrategy docs for full documentation.