I have a bit of code like so which works fine if the file in question doesn't already exist.
if AWS::S3::S3Object.exists? file_name, bucket.name + path_to_images
puts "file exists (deleting)"
AWS::S3::S3Object.delete file_name, bucket.name + path_to_images, :force => true
end
AWS::S3::S3Object.store file_name,
File.read(file_path),
bucket.name + path_to_images,
:content_type => 'image/png',
:access => :public_read
`rm #{file_path}`
The problem I'm having is if the file does exist, I want to overwrite it with a new copy... now I'm not sure if its a problem with overwriting it, so I tried deleting the file first if it already exists. That didn't seem to work either. So I assume it's either not deleting it, or it's cached too.
When displaying the image it of course trails with ?123232 a random number, I even tried deleting the browsers cache just for kicks.
I'm sure there's something easy I'm missing, and probably a more succinct way to do this anyway.
Thanks
UPDATE: I think the problem must have something to do with cloudfront or regular s3 caching, because eventually... it does update. But only after a day or so? And it is not my browser caching it, so it's probably this. Anyone know how to tell it to dump the cache?