이미지 크기를 조정하고 자르기 스크립트가 있습니다. 즉석에서 내 amazon S3에 이미지를 업로드하고 싶습니다.PHP SDK를 사용하여 amazon S3에 크기 조정 이미지 업로드
문제는 소스 파일이 디스크 ($ filepath)의 직접 경로로 인식되지 않기 때문에 스크립트를 실행하려고 할 때 오류 메시지가 표시된다는 것입니다. 이 상황을 극복 할 생각이 있습니까?
Fatal error: Uncaught exception 'Aws\Common\Exception\InvalidArgumentException' with message 'You must specify a non-null value for the Body or SourceFile parameters.' in phar:///var/www/submit/aws.phar/Aws/Common/Client/UploadBodyListener.php:...
$myResizedImage = imagecreatetruecolor($width,$height);
imagecopyresampled($myResizedImage,$myImage,0,0,0,0, $width, $height, $origineWidth, $origineHeight);
$myImageCrop = imagecreatetruecolor(612,612);
imagecopy($myImageCrop, $myResizedImage, 0,0, $posX, $posY, 612, 612);
//Save image on Amazon S3
require 'aws.phar';
use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;
$bucket = 'yol';
$keyname = 'image_resized';
$filepath = $myImageCrop;
// Instantiate the client.
$s3 = S3Client::factory(array(
'key' => 'private-key',
'secret' => 'secrete-key',
'region' => 'eu-west-1'
));
try {
// Upload data.
$result = $s3->putObject(array(
'Bucket' => $bucket,
'Key' => $keyname,
'SourceFile' => $filepath,
'ACL' => 'public-read',
'ContentType' => 'image/jpeg'
));
// Print the URL to the object.
echo $result['ObjectURL'] . "\n";
} catch (S3Exception $e) {
echo $e->getMessage() . "\n";
}
전체 코드를 게시 할 수 있습니까? 동일한 종류의 오류가 있습니다. – gnganpath
무엇이 필요합니까? – casusbelli