Adding and returning path using strapi-provider-upload-aws-s3

Hi,

I’m currently using the strapi-provider-upload-aws-s3 to upload images to an s3 bucket. See my current markup used in plugins.js below:


const moment = require(‘moment’)

module.exports = ({ env }) => ({
upload: {
provider: ‘aws-s3’,
providerOptions: {
accessKeyId: env(‘AWS_ACCESS_KEY_ID’),
secretAccessKey: env(‘AWS_SECRET_ACCESS_KEY’),
region: env(‘AWS_DEFAULT_REGION’),
params: {
Bucket: env(‘AWS_BUCKET’) + ‘/upload/’ + moment().year() + ‘/’ + moment().month() + ‘/’ + moment().date(),
},
},
},
delete: {
provider: ‘aws-s3’,
providerOptions: {
accessKeyId: env(‘AWS_ACCESS_KEY_ID’),
secretAccessKey: env(‘AWS_SECRET_ACCESS_KEY’),
region: env(‘AWS_DEFAULT_REGION’),
params: {
Bucket: env(‘AWS_BUCKET’) + ‘/upload’,
},
},
},
})


This is working fine in terms of being able to upload and delete images from s3. However, I’m using Cloudfront to handle caching. In order for this to work I need to use a relative path url instead of an absolute one that includes the s3 bucket name. For this I assumed I could use the path value that’s returned with each image in the formats array.

So my question is, is there a way to populate this path value on upload and have it returned when requesting the media using graphql? Failing that, is there a way of specifying a Cloudfront url when uploading media?

Any help on this would be much appreciated.

Thanks

Found this extension to the Strapi S3 provider that adds a cdnUrl parameter.

Does the job :+1:

able to upload the files tp S3 with this method but not getting URL append with the CDN DNS name, please help