列出所有文件在S3目录与Zend框架 [英] List all Files in a S3 Directory with Zend Framework

查看:307
本文介绍了列出所有文件在S3目录与Zend框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道我可以列出一个桶的Amazon S3的目录中的所有文件?

帮助AP preciated, 最好的问候,.wired

解决方案

见例如#5:

http://framework.zend.com/manual/ EN / zend.service.amazon.s3.html

  

getObjectsByBucket($桶)返回对象键列表,   盛装在吊桶

  $ S3 =新Zend_Service_Amazon_S3($ my_aws_key,$ my_aws_secret_key);

$名单= $ S3-> getObjectsByBucket(我 - 拥有 - 斗);
的foreach($清单为$名){
  回声我有$ name关键字:\ N的;
  $数据= $ S3->的getObject(我 - 拥有 - 桶/ $名称);
  回声数据:$ DATA \ N的;
}
 

更新:

在Amazon S3的

文件夹是prefixes,您可以设置一个参数:

  preFIX  - 限制响应该开始指示preFIX键。您可以使用prefixes分离桶成不同的密钥组在类似于文件系统如何使用文件夹的方式。
 

请参阅线#293 S3.php的

I wonder how I can list all files in an Amazon S3 Directory of a Bucket?

Help appreciated, best Regards, .wired

解决方案

See example #5:

http://framework.zend.com/manual/en/zend.service.amazon.s3.html

getObjectsByBucket($bucket) returns the list of the object keys, contained in the bucket.

$s3 = new Zend_Service_Amazon_S3($my_aws_key, $my_aws_secret_key);

$list = $s3->getObjectsByBucket("my-own-bucket");
foreach($list as $name) {
  echo "I have $name key:\n";
  $data = $s3->getObject("my-own-bucket/$name");
  echo "with data: $data\n";
}

Update:

"Folders" in amazon s3 are prefixes, you can set a param:

prefix - Limits the response to keys which begin with the indicated prefix. You can use prefixes to separate a bucket into different sets of keys in a way similar to how a file system uses folders.

See line #293 of S3.php

这篇关于列出所有文件在S3目录与Zend框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆