s3 = AWS::S3.newbucket = s3.buckets['test']bucket.exists? => true
假设我有一个名为demo / index.HTML的资源,我将如何检查此资源中是否存在此资源?
可能是我的问题太简单了,但我无法为此找到合适的答案.任何帮助表示赞赏.
解决方法 #exists? ⇒布尔值Returns true if the object exists in S3.
# new object,does not exist yetobj = bucket.objects["my-text-object"]# no instruction file presentbegin bucket.objects['my-text-object.instruction'].exists? #=> falserescue # exists? can raise an error `Aws::S3::Errors::ForbIDden`end# store the encryption materials in the instruction file# instead of obj#Metadataobj.write("MY TEXT",:encryption_key => MY_KEY,:encryption_materials_location => :instruction_file)begin bucket.objects['my-text-object.instruction'].exists? #=> truerescue # exists? can raise an error `Aws::S3::Errors::ForbIDden`end
http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/S3/S3Object.html#exists%3F-instance_method
总结以上是内存溢出为你收集整理的ruby – 如何检查AWS S3bucket中是否存在资源全部内容,希望文章能够帮你解决ruby – 如何检查AWS S3bucket中是否存在资源所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)