jeanbmar / payload-s3-upload

Send Payload CMS uploads to Amazon S3
MIT License
56 stars 9 forks source link

Add a s3Url field to directly expose s3 url in Payload API #2

Open jeanbmar opened 2 years ago

jeanbmar commented 2 years ago

In order to reduce overhead for developers, this:

fields: [
    {
      name: 'url',
      type: 'text',
      access: {
        create: () => false,
      },
      admin: {
        disabled: true,
      },
      hooks: {
        afterRead: [
          ({ data: doc }) =>
            `https://my-bucket.s3.eu-west-3.amazonaws.com/images/${doc.type}/${doc.filename}`,
        ],
      },
    },
  ],

will be replaced with this:

s3: {
  // ...
  s3Url: ({ doc }) => `https://my-bucket.s3.eu-west-3.amazonaws.com/images/${doc.type}/${doc.filename}`
},