亚马逊S3存储服务文件上传与获取工具(基于AWS sdk for PHP 3.x)
直接上代码
<?php
/**
* Desciption : 亚马逊S3文件管理工具类
*
* @author : [email protected]
* @date : 2018-09-19
*
*
*/
namespace Chunbo\Util;
vendor("Aws.aws-autoloader");
use Think\Log\LogHelper;
use Aws\S3\S3Client;
use Aws\S3\ObjectUploader;
class AwsFile
{
// 桶名称
const AWS_BUCKET = YOUR_BUCKEY_NAME;
private static $region = YOUR_REGION;//'cn-north-1'
private static $s3version = '2006-03-01';
private static $profile = 'default';
private static $_s3clients;
private static function uploadDemo()
{
//上传到服务器的临时文件
$file_name = $_FILES['aws_test']['tmp_name'];
// 获取数据流
$stream = file_get_contents