Skip to content

Instantly share code, notes, and snippets.

@kejyun
Created August 2, 2012 08:05
Show Gist options
  • Save kejyun/3235100 to your computer and use it in GitHub Desktop.
Save kejyun/3235100 to your computer and use it in GitHub Desktop.
上傳檔案至AWS S3容器中
<?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