Strapi Changed Upload Provider To S3

Hello! So I’ve recently just learned about using an upload provider for all my media in Strapi. I followed this documentation to use S3 bucket to store my media files:

Everything is working fine and I was surprised how easy it was! One caveat however, I noticed when I upload an image through the Strapi media library and then I check my S3 bucket, the original image file was there BUT also 4 other variants of the image called small, medium, large, and thumbnail. While I do find this logic very useful, I don’t need all these extra files in there and infact I would like to customize this feature.

My question is, how can I customize how the file gets processed and uploaded to S3? I would like to remove the extra variants as they’re not needed for these images and I would like to create a different kind of variant using my own logic. Is there a way to extend this plugin / upload processing logic?

I could not find any documentation on why these variants were being created nor how to customize it.

Thanks!

edit:
Here’s a screenshot of what the file variants look like.

So I was able to figure out a little more. I went into my node_modules where the plugin code was for the S3 provider and I was able to add in this code to prevent the variant file uploads. Basically just returning null if it’s a variant instead of the original image.

upload(file, customParams = {}) {
  if(['large', 'medium', 'small', 'thumbnail'].some(format => file.name.includes(format))) {
    return
  }
  // ...
}

From what I could tell, it’s not the provider / plugin that is creating these variants, it’s Strapi that calls this Upload function 5 times with different values for the “file” parameter pertaining to the various formats/variants.

Since this is a Strapi functionality, I think this should be documented somewhere and have the ability to turn it off/on and customize it more if necessary. Maybe there is a way already since I see there is a “customParams” parameter, but there isn’t any documentation pertaining to this that I’ve seen.

Looking forward to hearing someone’s response to this! This is my quick hack for now.

1 Like