4
我被迫使用AWS S3的第2版,因为我不能为了使用版本3如何从Amazon AWS S3版本2获取文件大小?
此服务器上更新PHP 5.5我做了这个PHP脚本从AWS,其工作好下载文件:
//http://docs.aws.amazon.com/aws-sdk-php/v2/api/class-Aws.S3.S3Client.html#_createPresignedUrl
// Get a command object from the client and pass in any options
// available in the GetObject command (e.g. ResponseContentDisposition)
$command = $s3Client->getCommand('GetObject', array(
'Bucket' => $bucket,
'Key' => $objectKey,
'ResponseContentDisposition' => 'attachment; filename="' . $originFilename . '"'
));
// Create a signed URL from the command object that will last for
// 10 minutes from the current time
$signedUrl = $command->createPresignedUrl('+1000 minutes');
$file = file_get_contents($signedUrl);
的问题是,我想肯定的是,file_get_contents()
下载整个文件,以检测和修复任何错误(如在下载过程中服务器脱机,等...),所以我想下面的流:
- 我问AWS的文件大小
- 我下载文件
- 我检查大小。如果不等于我重新下载文件
那么,如何从AWS获取文件大小呢?我发现this,但它不适用于我的版本。