@alexgao/storage-aliyun-oss
v3.82.1
Published
Payload storage adapter for Aliyun OSS
Readme
Aliyun OSS Storage for Payload
This package provides a simple way to use Aliyun OSS with Payload.
NOTE: This package removes the need to use @payloadcms/plugin-cloud-storage as was needed in Payload 2.x.
Installation
pnpm add @payloadcms/storage-aliyun-ossUsage
- Configure the
collectionsobject to specify which collections should use the Aliyun OSS adapter. The slug must match one of your existing collection slugs. - The
optionsobject can be anyOptionsobject (fromali-oss). This is highly dependent on your Aliyun OSS setup. Check the Aliyun OSS documentation for more information. - When enabled, this package will automatically set
disableLocalStoragetotruefor each collection. - When deploying to Vercel, server uploads are limited with 4.5MB. Set
clientUploadstotrueto do uploads directly on the client. You must allow CORS PUT method for the bucket to your website.
import { aliyunOssStorage } from '@payloadcms/storage-aliyun-oss'
import { Media } from './collections/Media'
import { MediaWithPrefix } from './collections/MediaWithPrefix'
export default buildConfig({
collections: [Media, MediaWithPrefix],
plugins: [
aliyunOssStorage({
collections: {
media: true,
'media-with-prefix': {
prefix,
},
},
bucket: process.env.ALIYUN_OSS_BUCKET,
options: {
accessKeyId: process.env.ALIYUN_OSS_ACCESS_KEY_ID,
accessKeySecret: process.env.ALIYUN_OSS_SECRET_ACCESS_KEY,
bucket: process.env.ALIYUN_OSS_BUCKET,
region: process.env.ALIYUN_OSS_REGION,
// ... Other Aliyun OSS configuration
},
}),
],
})Configuration Options
See the the Aliyun OSS SDK Package and Options object for guidance on Aliyun OSS configuration.
