如何在标准 - 不经常访问中上传大文件?
我的代码:
require('aws/aws-autoloader.php');
use Aws\S3\S3Client;
use Aws\S3\MultipartUploader;
$client = S3Client::factory(array(
'version' => 'latest',
'region' => 'us-east-1',
'credentials' => array(
'key' => $key,
'secret' => $secret,
),
));
$uploader = new MultipartUploader($client, $filename, [
'bucket' => $bucket,
'key' => $filename,
'part_size' => 1073741824,
]);
$uploader->upload();
文件上传正常,但在标准模式下,我想在不经常访问中上传。
答案 0 :(得分:1)
似乎需要使用回调挂钩¹来设置附加选项,例如存储类。
$uploader = new MultipartUploader($client, $filename, [
'bucket' => $bucket,
'key' => $filename,
'before_initiate' => function (\Aws\Command $command) {
// $command is a CreateMultipartUpload operation
$command['StorageClass'] = 'STANDARD_IA';
},
'part_size' => 1073741824,
]);
来源:
¹回调挂钩是一个我可能或者可能不会刚刚编写的术语,可能实际上也可能不是它的名称,但它似乎描述了这种机制。我不是PHP专家。