amazon s3 버킷에 이미지를 업로드 할 때 문제가 있습니다.
Amazon S3 - 제안 된 업로드가 허용 된 최소 크기보다 작습니다.
크기가 238 KB 인 jpg 이미지를 업로드하려고합니다. 오류가 무엇인지 확인하기 위해 코드에 try/catch를 넣었습니다. 나는 항상 다음과 같은 에러를 보게된다 :
Your proposed upload is smaller than the minimum allowed size
나는 또한 1MB와 2MB의 이미지에서 이것을 시도했다.
여기 내 코드입니다 : (. 내가 변경 한 양동이, 키 및 이미지 링크)
<?php
// Include the SDK using the Composer autoloader
require 'AWSSDKforPHP/aws.phar';
use Aws\S3\S3Client;
use Aws\Common\Enum\Size;
$bucket = 'mybucketname';
$keyname = 'images';
$filename = 'thelinktomyimage';
// Instantiate the S3 client with your AWS credentials and desired AWS region
$client = S3Client::factory(array(
'key' => 'key',
'secret' => 'secretkey',
));
// Create a new multipart upload and get the upload ID.
$response = $client->createMultipartUpload(array(
'Bucket' => $bucket,
'Key' => $keyname
));
$uploadId = $response['UploadId'];
// 3. Upload the file in parts.
$file = fopen($filename, 'r');
$parts = array();
$partNumber = 1;
while (!feof($file)) {
$result = $client->uploadPart(array(
'Bucket' => $bucket,
'Key' => $keyname,
'UploadId' => $uploadId,
'PartNumber' => $partNumber,
'Body' => fread($file, 5 * 1024 * 1024),
));
$parts[] = array(
'PartNumber' => $partNumber++,
'ETag' => $result['ETag'],
);
}
// Complete multipart upload.
try{
$result = $client->completeMultipartUpload(array(
'Bucket' => $bucket,
'Key' => $keyname,
'UploadId' => $uploadId,
'Parts' => $parts,
));
$url = $result['Location'];
fclose($file);
}
catch(Exception $e){
var_dump($e->getMessage());
}
사람이 전에이 있었나요? 인터넷 검색은 나에게별로 도움이되지 못했습니다.
최소 업로드 크기를 변경해도 많은 도움이되지 않았습니다.
UPDATE : 나는 로컬 이미지와 함께이 시도
이 (파일 이름 변경)을 일했다! 온라인 이미지로 어떻게이 작업을 할 수 있습니까? 이제 임시 파일에 저장 한 다음 업로드합니다. 하지만 로컬에 저장하지 않고 직접 저장하는 방법은 없습니까?
멀티 파트 업로드 API는 임의의 크기의 물체를 업로드 할 수 있습니다. 유일한 요구 사항은 마지막 부분을 제외한 모든 "부분"이 적어도 5MB 여야한다는 것입니다. fread()는 크기가 5MB보다 작은 문자열을 반환합니다. – Jesse