-------------------------------------------------------------------------------------------------

STEP - 01 .Credential 엑세스 키 페어 생성

     1. aws 콘솔에 접속
     2. 우상단에 본인의 계정명을 클릭


     3. 펼쳐진 메뉴박스에서 '내 보안 자격증명' 을 클릭


     4. 보안 자격 증명 페이지가 나오고, 아코디언 메뉴중에 '액세스 키'가 있는데 열어보면 다음과 같은 화면이 나온다.


     5. 키 / 보안키 값을 별도로 보관

-------------------------------------------------------------------------------------------------

 

STEP - 02 . AWS SDK 설치 ( composer )

shell> composer install
shell> composer require aws/aws-sdk-php
shell> composer require aws/aws-php-sns-message-validator

 

STEP - 03. PHP CODE 작성

require './vendor/autoload.php';

use Aws\Sdk;

// Create an SDK class used to share configuration across clients.
$sdk = new Aws\Sdk(
    [
        'version' 	=> 'latest',
        'region' 	=> 'ap-northeast-2',
        'credentials' => [
            'key' => '[]',
            'secret' => '[]'
        ]
    ]
);

// Use an Aws\Sdk class to create the S3Client object.
$s3Client = $sdk->createS3();

$bucket 	= '[ AWS S3 버킷이름 ]';
$source 	= '[ 업로드 대상 파일 경로 ]';
$uploadKey  = '[ AWS S3 저장시 사용될 파일명 ]';


// Send a PutObject request and get the result object.
$result = $s3Client->putObject([
    'Bucket' 		=> $bucket,
    'Key'    		=> $uploadKey,
    'SourceFile'   	=> $source,
#    'ACL'    		=> 'public-read-write' ( ACL 설정에 따라서 필요할 수 있음 )
]);

//echo "<pre>";
//var_export( $result );
//echo "</pre>";