Closed Arepo closed 4 years ago
The best way to work around this is to add a random fingerprint to the image name. Something like the current unix time works well. The file name won't be exactly what the user supplied, but it is guaranteed to force reprocessing. Be sure to set the name before you try to attach it (i.e. do it outside the uploader), otherwise the fingerprint may change between version processing and the version filenames won't match.
Fingerprinting is a good practice anyhow if you're using a CDN in front of your assets because it immediately busts the cache.
Our app uses the mini_magick gem to allow cropping of uploaded images. This means there's a reasonable chance that, having uploaded an avatar, a user might upload the same file wanting to crop it differently. But as far as I can tell, there's some baked in logic that retains the filename somewhere, meaning that when they attempt to upload a file with the same name, the original file is just reused, discarding (eg) changes to cropping. I can't tell whether this logic comes from carrierwave-aws, carrierwave, or Rails itself, or even somewhere else, but I'm hoping some kindly contributor here could point me in the right direction if I'm in the wrong place (or help me to change the behaviour if I'm not!)