我正在尝试从亚马逊 S3 存储桶子文件夹中获取所有文件,并使其可在网页中下载。
我有一个名为图像的存储桶。在那个桶里面我有一些其他的文件夹。现在我正在尝试获取该子文件夹中的所有文件并将其显示在页面中。S3 存储桶: /images /images/test1/ /images/test2/ /images/test1/1 /images/test1/2 /images/test1/1/item
我试过这样,但无法得到预期的结果。
// Target files full path : images/test1/1/item
$bucketName = 'images';
$source = '/test1/1/item'
$image = $this->s3->getBucket($bucketName);
foreach ($image as $key=>$data){
$k = $data['name'];
print_r($k); // now this gives me full list of everything inside the images bucket.
}
现在,如果我想从存储桶中获取对象,我可以使用 getObject,我试过这样:
$result = $this->s3->getObject($image); // I am confused about this one
任何建议将不胜感激。谢谢,
在使用 Josue Ibarra 的以下答案后,我得到了这样的结果
(
[tableuploads/1/emaillists/15.10.2013-18.03.23-emailList.csv] => Array
(
[file_name] => 15.10.2013-18.03.23-emailList.csv
[file_folder] => emaillists
[file_size] => 64
[created_on] => 2013-10-15 19:03:26
[s3_link] => http://s3.amazonaws.com/webtools_sharing/emaillists/15.10.2013- 18.03.23-emailList.csv
[md5_hash] => 4809ae0b75d3517b69f69b53ba0b2959
)
[tableuploads/1/emaillists/15.10.2013-18.04.32-emailList.csv] => Array
(
[file_name] => 15.10.2013-18.04.32-emailList.csv
[file_folder] => emaillists
[file_size] => 64
[created_on] => 2013-10-15 19:04:45
[s3_link] => http://s3.amazonaws.com/webtools_sharing/emaillists/15.10.2013-18.04.32-emailList.csv
[md5_hash] => 14094e133779619ddfcfc008d16ce75b
)
[tableuploads/2/emaillists/15.10.2013-18.03.23-emailList.csv] => Array
(
[file_name] => 15.10.2013-18.03.23-emailList.csv
[file_folder] => emaillists
[file_size] => 64
[created_on] => 2013-10-15 19:03:26
[s3_link] => http://s3.amazonaws.com/webtools_sharing/emaillists/15.10.2013-18.03.23-emailList.csv
[md5_hash] => 4809ae0b75d3517b69f69b53ba0b2959
)
[tableuploads/2/emaillists/15.10.2013-18.04.32-emailList.csv] => Array
(
[file_name] => 15.10.2013-18.04.32-emailList.csv
[file_folder] => emaillists
[file_size] => 64
[created_on] => 2013-10-15 19:04:45
[s3_link] => http://s3.amazonaws.com/webtools_sharing/emaillists/15.10.2013-18.04.32-emailList.csv
[md5_hash] => 14094e133779619ddfcfc008d16ce75b
)
)
我想要这样的东西: http : //s3.amazonaws.com/webtools_sharing/tableuploads/1/emaillists/15.10.2013-18.03.23-emailList.csv
http://s3.amazonaws.com/webtools_sharing/tableuploads/2/emaillists/15.10.2013-18.03.23-emailList.csv
这需要是一个可下载的链接。
请建议我链接或给我一些想法,我该怎么做。