Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/growingio/payload-oss-plugin
Payload CMS plugin used for uploading files to OSS.
https://github.com/growingio/payload-oss-plugin
Last synced: about 1 month ago
JSON representation
Payload CMS plugin used for uploading files to OSS.
- Host: GitHub
- URL: https://github.com/growingio/payload-oss-plugin
- Owner: growingio
- License: mit
- Created: 2024-03-22T10:44:11.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-03-25T06:15:41.000Z (9 months ago)
- Last Synced: 2024-10-28T15:59:41.489Z (about 2 months ago)
- Language: JavaScript
- Size: 185 KB
- Stars: 1
- Watchers: 6
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Upload files to AliYun OSS in Payload CMS
This plugin sends uploaded files to AliYun OSS instead of writing them to the server file system.
## Why should I use this module?
Payload team supports an official cloud storage plugin, different from this one.
The main difference is that this plugin allows configuring collection logic on the collection itself.
Payload implementation requires to define collection-specific stuff from plugins inside the global payload configuration
file, which is (imho) bad design.## How to use in my project?
### Install
`npm install --save @gio/payload-oss-plugin --legacy-peer-deps`
Payload requires `legacy-peer-deps` because of conflicts on React and GraphQL dependencies (see
Payload [docs](https://payloadcms.com/docs/getting-started/installation)).### Configure your payload config with oss plugin
```js
import OssPlugin from '@gio/payload-oss-plugin'export default buildConfig({
// ...
plugins: [
OssPlugin({
enabled: true,
region: process.env.PAYLOAD_PUBLIC_OSS_REGION,
accessKeyId: process.env.PAYLOAD_PUBLIC_OSS_ACCESS_KEY_ID,
accessKeySecret: process.env.PAYLOAD_PUBLIC_OSS_ACCESS_KEY_SECRET,
bucketName: process.env.PAYLOAD_PUBLIC_OSS_BUCKET_NAME,
bucketPath: process.env.PAYLOAD_PUBLIC_OSS_BUCKET_PATH,
}),
],
});
```### Configure your upload collections
```js
const Media: CollectionConfig = {
slug: 'media',
upload: {
staticURL: '/assets',
staticDir: 'assets',
disableLocalStorage: true,
adminThumbnail: ({doc}) =>
`${process.env.PAYLOAD_PUBLIC_OSS_ENDPOINT}${process.env.PAYLOAD_PUBLIC_OSS_BUCKET_PATH}/${doc.filename}`,
},
fields: [
{
type: 'text',
name: 'title'
}
],
}export default Media;
```## At last
Thanks and that`s all.