且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

检查s3存储桶中是否存在文件夹

更新时间:2021-10-07 06:36:34

使用 Bucket#objects :

bucket.objects({prefix: 'my/folder/'}).limit(1).any?

返回 ObjectSummary 资源的 Collection .没有API请求直到在集合上调用可枚举的方法为止. Client#list_objects 将被多次调用,直到每次 ObjectSummary 已产生.

Returns a Collection of ObjectSummary resources. No API requests are made until you call an enumerable method on the collection. Client#list_objects will be called multiple times until every ObjectSummary has been yielded.

- http://docs.aws.amazon.com/sdkforruby/api/Aws/S3/Bucket.html#objects-instance_method