keystonejs / keystone-storage-adapter-s3

⚠️ Archived - Legacy S3 Storage Adapter for KeystoneJS
MIT License
17 stars 55 forks source link

Cloudfront support #17

Closed fbritoferreira closed 7 years ago

fbritoferreira commented 7 years ago

It would be nice if we could had a separate cloudfront / cdn link and would pull the files from there.

sktt commented 7 years ago

Hey! This does not need to be handled by the storage adapter.

You can create the cloudfront link using built-in mongoose hooks

MyModel.schema.pre('save', function(next) {
  var field = this.s3file

  cloudfront.createDistribution({
  }, next);
});

see https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudFront.html#createDistribution-property and http://mongoosejs.com/docs/middleware.html

fbritoferreira commented 7 years ago

@sktt Good shout thats a really easy way of doing it.