aws-s3
aws-s3 copied to clipboard
Blank URL should not exist as an S3Object
Hello,
I think this is personal taste so I would not count this as an issue, but here is my doubt:
AWS::S3::S3Object.exists?( "", "mybucket")
I don't think this should return true because there is no S3Object.
I understand the logic behind it as the URL exists, this is the address of the bucket itself.
But in the way it is accessed here, it does not make much sense.
Especially when the find method raises an error:
AWS::S3::S3Object.find( "", "mybucket") #=> NoMethodError: undefined method `-' for nil:NilClass
At least both should be consistent in terms of failure-or-not. Also I understand that looking for a blank filename is stupid, but it makes sense if the name is generated. I personally encountered this while building some tests/specs.
My test was originally having nil as a filename and it raises an error so I thought I could just pass it through Nil#to_s and that is when I had my test failing while it was imho correct.
What do you guys think about that? I'm looking forward to hearing your opinion.
Thank you for reading Mig
In fact I expected a behaviour similar to:
AWS::S3::Bucket.objects('mybucket').map{|o|o.key}.member?( "" )