최근에 나는 이것을위한 코드 샘플을 준비했습니다. 이 예제에서는 파일을 사용하고 있지만 스트림도 사용할 수 있습니다.
use Aws\S3\S3Client;
use Aws\Common\Enum\Size;
// Instantiate the client.
$s3 = S3Client::factory(array(
'key' => '*** your-aws-access-key-id ***',
'secret' => '*** your-aws-secret-key ***'
));
$file = fopen($filename, 'r');
// 1. Create a new multipart upload and get the upload ID.
$response = $s3->createMultipartUpload(array(
'Bucket' => $bucket,
'Key' => $keyname
);
$uploadId = $result['UploadId'];
// 2. Upload the data in parts.
$parts = array();
$partNumber = 1;
while (!feof($file)) {
$result = $s3->uploadPart(array(
'Bucket' => $bucket,
'Key' => $key,
'UploadId' => $uploadId,
'PartNumber' => $partNumber,
'Body' => fread($file, 5 * Size::MB),
));
$parts[] = array(
'PartNumber' => $partNumber++,
'ETag' => $result['ETag'],
);
}
// 3. Complete multipart upload.
$result = $s3->completeMultipartUpload(array(
'Bucket' => $bucket,
'Key' => $key,
'UploadId' => $uploadId,
'Parts' => $parts,
));
$url = $result['Location'];
fclose($file);
크기가 107MB 인이 파일을 업로드하려고합니다. 하지만 s3에서 로그를 확인하면 파일이 업로드되지 않습니다.이 파일의 일부분 인 "IncompleteBody"가 표시됩니다. 어떻게 처리해야합니까 ?? – Aryan
이이 로그에 표시 것입니다 : REST.PUT.PART 4분의 6/5_34fa2f47f8f2e3d/645_d48b407b9d44efc.mp4을 "PUT /my.bucket/6/4/5_34fa2f47f8f2e3d/645_d48b407b9d44efc.mp4?partNumber=5&uploadId=C9utxlgdMqWCKrYuOEWyE2TOANRjx9r8YnDL3YV53kHVjEAGQ55U3IjqxodIAJRlbdQS8Fd5kWhHdlL_8kg-- HTTP/1.1 "400 IncompleteBody 260 5242880 3356 -"- ""aws-sdk-php2/2.8.20 Guzzle/3.9.3 curl/7.30.0 PHP/5.3.28 " 이 솔루션"http : // docs .aws.amazon.com/AmazonS3/latest/dev/usingHLmpuPHP.html "하지만 동일한 문제가 발생합니다. – Aryan