Php 我无法从主服务器移动S3存储桶中的图像
我想将我的图片上传到amazon s3存储桶中。我的图像数据库已上载到另一个web服务器。我无法将其移动到S3桶中。我参考了StackOverflow的一些解决方案 以下是我尝试过的代码:Php 我无法从主服务器移动S3存储桶中的图像,php,amazon-web-services,amazon-s3,Php,Amazon Web Services,Amazon S3,我想将我的图片上传到amazon s3存储桶中。我的图像数据库已上载到另一个web服务器。我无法将其移动到S3桶中。我参考了StackOverflow的一些解决方案 以下是我尝试过的代码: use \usr\share\php\AWSSDKforPHP\S3; use \usr\share\php\AWSSDKforPHP\S3\S3Client; use \usr\share\php\AWSSDKforPHP\S3\Exception\S3Exception; $bucket = 'cdn.
use \usr\share\php\AWSSDKforPHP\S3;
use \usr\share\php\AWSSDKforPHP\S3\S3Client;
use \usr\share\php\AWSSDKforPHP\S3\Exception\S3Exception;
$bucket = 'cdn.example.com';
$keyname = $newfilename;
$s3 = new S3Client([
'version' => 'latest',
'region' => 'us-east-1',
'credentials' => [
'key' => "**********************",
'secret' => "**********************************"
]
]);
try {
// Upload data.
$result = $s3->putObject([
'Bucket' => $bucket,
'Key' => $keyname,
'SourceFile' => $oldfilepath,
'ACL' => 'public-read'
]);
// Print the URL to the object.
echo $result['ObjectURL'] . PHP_EOL;
} catch (S3Exception $e) {
echo $e->getMessage() . PHP_EOL;
}
显示输出错误:
use \usr\share\php\AWSSDKforPHP\S3;
use \usr\share\php\AWSSDKforPHP\S3\S3Client;
use \usr\share\php\AWSSDKforPHP\S3\Exception\S3Exception;
$bucket = 'cdn.example.com';
$keyname = $newfilename;
$s3 = new S3Client([
'version' => 'latest',
'region' => 'us-east-1',
'credentials' => [
'key' => "**********************",
'secret' => "**********************************"
]
]);
try {
// Upload data.
$result = $s3->putObject([
'Bucket' => $bucket,
'Key' => $keyname,
'SourceFile' => $oldfilepath,
'ACL' => 'public-read'
]);
// Print the URL to the object.
echo $result['ObjectURL'] . PHP_EOL;
} catch (S3Exception $e) {
echo $e->getMessage() . PHP_EOL;
}
致命错误:在第35行的/var/www/html/cron jobs/shift-img.php中找不到类“usr\share\php\AWSSDKforPHP\S3\S3Client”
“S3Client”未安装或配置不正确。您如何证明这一点?我们已经检查过它是否安装正确。S3Client文件已经在我手动检查过的文件夹中。它是否需要
require'vendor/autoload.php'代码>?有一些示例代码在:您的S3Client未找到,这就是为什么我告诉您未正确安装或配置。“S3Client”未安装或未正确配置。您如何证明这一点?我们已经检查过它是否安装正确。S3Client文件已经在我手动检查过的文件夹中。它是否需要require'vendor/autoload.php'代码>?这里有一些示例代码:您的S3Client未找到,这就是我告诉您未正确安装或配置的原因。