amazon web services - Rails : undefined method `exists?' for AWS::S3::S3Object:Class -


i'm using aws-sdk gem , trying verify if file uploaded bucket exists. i'm using paperclip 2.7.

this method seems not work:

if record.image , aws::s3::s3object.exists? record.image, "mybucket-dev" 

i think aws::s3::s3object.exists? method old gem aws-s3 ?

what method can use test if file present in bucket ?

in fact, real path want check that:

record.image.to_file(:tiny).path  

(the tiny version of image)

thanks.

try this

aws::s3.new.buckets["bucket"].objects["file path on s3"].exists? 

the above code return true if file exists else returns false.

for future reference please refer http://docs.aws.amazon.com/awsrubysdk/latest/aws/s3/s3object.html#

hope helps.


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -