feat: add support for s3 bucket for media

This commit is contained in:
ArraysID
2025-05-11 05:24:31 +07:00
parent d1fc7a8fd5
commit 74aabd1eba
5 changed files with 1796 additions and 23 deletions
+5
View File
@@ -2,3 +2,8 @@ VITE_API_URL=
CMS_SECRET=
CMS_POSTGRES_URL=
CMS_STORAGE_ENDPOINT=
CMS_STORAGE_ACCESS_KEY_ID=
CMS_STORAGE_SECRET_ACCESS_KEY=
CMS_STORAGE_REGION=ap-southeast-1
@@ -1 +1,6 @@
export const importMap = {};
import { S3ClientUploadHandler as S3ClientUploadHandler_f97aa6c64367fa259c5bc0567239ef24 } from '@payloadcms/storage-s3/client';
export const importMap = {
'@payloadcms/storage-s3/client#S3ClientUploadHandler':
S3ClientUploadHandler_f97aa6c64367fa259c5bc0567239ef24,
};
+25 -1
View File
@@ -1,5 +1,8 @@
import { postgresAdapter } from '@payloadcms/db-postgres';
import { lexicalEditor } from '@payloadcms/richtext-lexical';
import { s3Storage } from '@payloadcms/storage-s3';
import { NodeHttpHandler } from '@smithy/node-http-handler';
import https from 'https';
import path from 'path';
import { buildConfig } from 'payload';
import sharp from 'sharp';
@@ -40,5 +43,26 @@ export default buildConfig({
},
}),
sharp,
plugins: [],
plugins: [
s3Storage({
collections: {
media: {
disableLocalStorage: true,
},
},
bucket: 'landing-cms',
config: {
endpoint: process.env.CMS_STORAGE_ENDPOINT,
credentials: {
accessKeyId: process.env.CMS_STORAGE_ACCESS_KEY_ID!,
secretAccessKey: process.env.CMS_STORAGE_SECRET_ACCESS_KEY!,
},
region: process.env.CMS_STORAGE_REGION!,
forcePathStyle: true,
requestHandler: new NodeHttpHandler({
httpsAgent: new https.Agent({ rejectUnauthorized: false }),
}),
},
}),
],
});
+1758 -21
View File
File diff suppressed because it is too large Load Diff
+2
View File
@@ -31,7 +31,9 @@
"@payloadcms/db-postgres": "^3.37.0",
"@payloadcms/next": "^3.37.0",
"@payloadcms/richtext-lexical": "^3.37.0",
"@payloadcms/storage-s3": "^3.37.0",
"@radix-ui/react-slot": "^1.2.0",
"@smithy/node-http-handler": "^4.0.4",
"@tanstack/react-query": "^5.74.4",
"@tanstack/react-store": "^0.7.0",
"@tanstack/react-table": "^8.21.2",