在使用 aws/aws-sdk-php(:2.*) 时,我注册了 S3 流包装器,以便将原生 PHP 文件函数与“s3://”流结合使用。
问题: 通过 native PHP 函数将对象放入 S3 时,有没有办法启用服务器端加密? 默认情况下,对象存储到 S3 时不进行任何加密。
附带说明一下,该应用程序使用 ZF1 Zend_File_Transfer 从表单上传文件。
最佳答案
将stream_context_create与fopen结合使用:
$s3FilePath = "s3://yourbucket/folder/file";
$context = stream_context_create(array(
's3' => array('ServerSideEncryption' => 'AES256')
));
$stream = fopen($s3FilePath, 'w', false, $context);
fwrite($stream, "Your Data");
fclose($stream);
或者,您可以使用存储桶策略。
关于php - AWS PHP S3 流包装服务器端加密,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37659747/