简体   繁体   English

如何在不指定目的地的情况下下载AWS S3存储桶PHP

[英]How to download AWS S3 bucket PHP without specifying destination

I've been following this guide https://docs.aws.amazon.com/aws-sdk-php/v3/guide/service/s3-transfer.html , but I'd like to be able to automatically download the bucket to a computer's download folder (maybe even tar.gz it). 我一直在遵循本指南https://docs.aws.amazon.com/aws-sdk-php/v3/guide/service/s3-transfer.html ,但我希望能够自动下载存储桶到计算机的下载文件夹(甚至是tar.gz)。 I tried not specifying a destination, but it is a mandatory parameter. 我尝试不指定目的地,但这是必填参数。 Should I just traverse each instead, or is there a way to use AWS transfer manager for PHP in order to achieve my desired behavior? 我应该只是遍历每个对象,还是有办法使用AWS Transfer Manager for PHP来实现我想要的行为?

If you are looking to output it straight to the visitor 如果您希望将其直接输出给访问者

<?php
    header('Content-Disposition: attachment; filename="FILE.NAME"');

    $s3 = new S3($key, $secret);
    $s3->getObject("BUCKETNAME", "FILE.NAME", fopen("php://output", "wb"));

 ?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM