How should I insert pictures with a dynamically defined folder to S3 CFS store?

I need to upload pictures to S3, so far I’m thinking of using the S3 store for CollectionFS. What I’m wondering is how I should implement picture insertion into the store, while defining the S3 folder based on user parameters.

I’ve defined my pictures collection (Pictures) and its S3 store (pictureStore) as follows:

pictureStore = new FS.Store.S3("projects", {
  accessKeyId: getSetting("s3AccessKeyId"),
  secretAccessKey: getSetting("s3SecretAccessKey"),
  bucket: getSetting("s3Bucket"),
})
@Pictures = new FS.Collection("pictures", {
  stores: [pictureStore],
  allow: {
    contentTypes: ["image/*",],
  },
})

As you might notice, I haven’t defined the folder property of the S3 store. The reason is that the folder should depend on user parameters at the time of insertion. How should I define the folder when inserting pictures into the store?

Should I perhaps consider an alternative approach/library for uploading to S3?

1 Like

+1 for your question.

I ended up using Slingshot FWIW.