更新时间:2022-03-26 22:20:01
您可以结合使用PHP SDK中的两个功能。
You can do this with a combination of two features in the PHP SDK.
首先,签出 S3Client :: uploadDirectory()
方法(请参见用户指南)。您可以像这样上传一会儿目录的内容:
First, checkout the S3Client::uploadDirectory()
method (see user guide). You can upload a while directory's contents like this:
$s3Client->uploadDirectory('/local/directory', 'your-bucket-name');
如果将其与 S3 Stream Wrapper ,然后您可以指定使用本地目录作为源
If you combine this with the S3 Stream Wrapper, then instead of using a local directory as the source, you can specify a bucket.
$s3Client->registerStreamWrapper();
$s3Client->uploadDirectory('s3://your-other-bucket-name', 'your-bucket-name');
此功能非常强大,因为如果使用不同配置的 uploadDirectory()的对象相比,Stream Wrapper的c $ c> S3Client 对象。
This is pretty powerful, because you can even do something across regions if you use a differently configured S3Client
object for the Stream Wrapper than the one doing the uploadDirectory()
.