【问题标题】:set up expiration for putObject in s3 php sdk在 s3 php sdk 中为 putObject 设置过期
【发布时间】:2014-11-10 08:32:09
【问题描述】:

这是创建bucket和putObject的工作代码:

$bucket = uniqid("php-sdk-sample-", true);
echo "Creating bucket named {$bucket}\n";
$result = $client->createBucket(array(
'Bucket' => $bucket
));
// Wait until the bucket is created
$key = 'hello_world.txt';
echo "Creating a new object with key {$key}\n";
$result = $client->createObject(array(
'Bucket' => $bucket,
'Key'    => $key,
'Body'   => "Hello World!" 
));

如何为这个刚刚创建的对象设置过期日期?例如。我想看到上传的文件在 3 天后消失。

【问题讨论】:

    标签: php amazon-s3 aws-php-sdk


    【解决方案1】:

    您需要先阅读和了解S3 object lifecycle management,然后才能使用putBucketLifecycle operation 进行配置。

    【讨论】:

      【解决方案2】:

      我想通了。虽然它不适用于 sdk 2.6.*,但这解决了问题; create_object_expiration_config ( $bucket, $opt ) 在 SDK 1.6.2 中。

      这是link.

      【讨论】:

      • 我已经从 sdk 1.6.2 实现了一些文件,并在上面使用了这个方法。
      猜你喜欢
      • 2012-11-10
      • 2015-12-05
      • 2016-10-08
      • 1970-01-01
      • 1970-01-01
      • 2012-03-04
      • 1970-01-01
      • 1970-01-01
      • 2022-07-05
      相关资源
      最近更新 更多