【发布时间】:2018-12-19 17:11:54
【问题描述】:
我对使用哪个函数来显示位于 bucketname/plain.txt 位置的文本文件感到困惑。
有人可以说明我应该做什么吗?
<?php
?>
<html>
<head><title>PHP says hello</title></head>
<body>
<b>
<?php
$client = new Aws\S3\S3Client([/** options **/]);
// Register the stream wrapper from an S3Client object
$client->registerStreamWrapper();
// Download the body of the "key" object in the "bucket" bucket
$data = file_get_contents('s3://vetri/plain.txt');
// Open a stream in read-only mode
if ($stream = fopen('s3://vetri/plain.txt', 'r')) {
// While the stream is still open
while (!feof($stream)) {
// Read 1024 bytes from the stream
echo fread($stream, 1024);
}
// Be sure to close the stream resource when you're done with it
fclose($stream);
}
?>
</b>
</body>
</html>
【问题讨论】:
-
为什么不用API中的Bucket对象呢?为什么不阅读 AWS PHP api 文档?
-
以下是您应该阅读和实施的示例:docs.aws.amazon.com/AmazonS3/latest/dev/…
标签: php amazon-web-services amazon-s3 aws-php-sdk