Created
August 2, 2012 08:05
-
-
Save kejyun/3235100 to your computer and use it in GitHub Desktop.
上傳檔案至AWS S3容器中
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* 上傳檔案至S3容器中 | |
*/ | |
$bucket = "kejyun-test"; //容器名稱 | |
$s3_remote = array( | |
"filename" => "S3.txt", //檔案名稱 | |
"dir" => "/", //檔案路徑 | |
"file_privilege"=> AmazonS3::ACL_PUBLIC, //檔案存取權限 | |
"contentType" => "text/plain", //檔案mime type | |
"storage_type" => AmazonS3::STORAGE_REDUCED, //檔案儲存類型 | |
); | |
$local = array( | |
"filename" =>"local_file.txt", //檔案名稱 | |
"dir" =>"/", //檔案路徑 | |
); | |
$upload_option = array( | |
"fileUpload" => $local["dir"].$local["filename"] , //檔案存放位置及檔名 | |
"acl" => $s3_remote["file_privilege"], //檔案存取權限 | |
"contentType" => $s3_remote["contentType"], //檔案mime type | |
"storage" => $s3_remote["storage_type"], //檔案儲存類型 | |
); | |
$s3 = new AmazonS3(); | |
$s3->create_object($bucket , $s3_remote["dir"].$s3_remote["filename"] , $upload_option); | |
print_r($response); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment