Store images and other assets with Digital Ocean Spaces object storage.
Integration type
Category
Repository
Package
Last published
Downloads in past month
Digital Ocean Spaces is an S3-compatible object storage solution.
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
packages installed:
npm install @aws-sdk/client-s3 @aws-sdk/lib-storage
In the Digital Ocean dashboard, navigate to “Spaces Object Storage” from the left nav menu and create a new bucket named “vendure-assets”.
Next, navigate to the “API” section and generate a new API key for that bucket. Be sure to note down:
These can then be used to configure the environment variables SPACES_ACCESS_KEY
, SPACES_SECRET_KEY
and SPACES_ENDPOINT
.
// vendure-config.ts
import { AssetServerPlugin, configureS3AssetStorage } from '@vendure/asset-server-plugin';
import { DefaultAssetNamingStrategy } from '@vendure/core';
// ...
plugins: [
AssetServerPlugin.init({
route: 'assets',
assetUploadDir: path.join(__dirname, 'assets'),
namingStrategy: new DefaultAssetNamingStrategy(),
storageStrategyFactory: configureS3AssetStorage({
bucket: 'vendure-assets',
credentials: {
accessKeyId: process.env.SPACES_ACCESS_KEY,
secretAccessKey: process.env.SPACES_SECRET_KEY,
},
nativeS3Configuration: {
endpoint: process.env.SPACES_ENDPOINT?? 'http://localhost:9000',
forcePathStyle: true,
signatureVersion: 'v4',
// The `region` is required by the AWS SDK,
// so we just use a dummy value here.
region: 'eu-west-1',
},
}),
}),
See the S3AssetStorageStrategy docs for full documentation.