payloadcms / payload

Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.
https://payloadcms.com
MIT License
23.58k stars 1.5k forks source link

plugin-cloud-storage: Documents created through admin panel don't utilize configuration prefix #4840

Open mstone121 opened 1 year ago

mstone121 commented 1 year ago

I'm using the s3 adapter to attach files to a collection. When I use the REST API endpoints and don't supply a prefix, the configuration value is used. This is expected and working well.

When I try to create a new document from the admin panel, the prefix is ignored. Inspecting the request revealed that the admin panel is sending "prefix": "." in the payload along with the other fields. The uploadHandler picks up this value and uses it to override the configuration prefix: https://github.com/payloadcms/plugin-cloud-storage/blob/3d5858ca6d45d73c22e9bb97c2b443758d93400b/src/adapters/s3/handleUpload.ts#L27

I checked the Payload configuration and it does seem to be setting the default value correctly:

{
  name: 'prefix',
  type: 'text',
  admin: { readOnly: true, hidden: true },
  defaultValue: 'my custom value from .env file',
  label: 'Prefix',
  validate: [Function (anonymous)],
  hooks: {},
  access: {}
}

so I wonder if this might be more of an issue with Payload CMS and not this plugin. If so, feel free to close this and I'll open up an issue there.

paulpopus commented 8 months ago

This plugin is now being maintained in the Packages Directory of the Payload Monorepo. This repo will soon be archived and all open issues will be closed. This issue, however, will be transferred over.