ruby on rails - Check if a file exists on AWS S3 path using aws-sdk gem -
i trying check whether particular pdf file exists on aws s3 using aws-sdk gem (version 2) inside ruby on rails application.
i have aws connection established , using exists? method:
puts @bucket.objects(prefix:"path/sample_100.pdf").exists?
on running above statement, below no method error:
undefined method 'exists?' aws::resources::collection
checked few documents of not help. there other way achieve same.
thanks in advance
i'm not ruby developer myself, might able suggest something.
the usual way check whether object exists in amazon s3 using head object operation. basically, returns metadata (but no content) of object if exists, or 404 error if doesn't. it's object, without contents of object.
i looked in aws sdk ruby api reference , found method:
http://docs.aws.amazon.com/sdkforruby/api/aws/s3/client.html#head_object-instance_method
take @ that, it's looking for.
Comments
Post a Comment