Skip to content

Instantly share code, notes, and snippets.

@kejyun
kejyun / aws_sdk_listbucket_example.php
Created April 9, 2012 15:16
AWS SDK List Bucket Example
<?php
error_reporting(-1);
header("Content-type: text/plain; charset=utf-8");
require_once "aws-sdk-for-php/sdk.class.php";
$s3 = new AmazonS3();
$response = $s3->list_buckets();
print_r($response);
?>
@kejyun
kejyun / aws_sdk_ssl_certificate_solution_1.php
Created April 9, 2012 15:22
AWS SDK SSL certificate problem solution 1
<?php
// =========== 前略 ===========
// Verification of the SSL cert
if ($this->ssl_verification)
{
curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_handle, CURLOPT_SSL_VERIFYHOST, false);
}
else
{
@kejyun
kejyun / aws_sdk_ssl_certificate_solution_2.php
Created April 9, 2012 15:33
AWS SDK SSL certificate problem solution 2
<?php
error_reporting(-1);
header("Content-type: text/plain; charset=utf-8");
require_once "aws-sdk-for-php/sdk.class.php";
$s3 = new AmazonS3();
//********** 多加這一行 **********
$s3->ssl_verification=false;
//********** 多加這一行 **********
$response = $s3->list_buckets();
@kejyun
kejyun / aws_s3_php_sdk_add_bucket.php
Created August 2, 2012 07:56
建立AWS S3容器
<?php
/*
* 建立容器
*/
//容器名稱
$bucket = "kejyun-test";
$s3 = new AmazonS3();
$response = $s3->create_bucket($bucket , $s3::REGION_SINGAPORE);
print_r($response);
?>
@kejyun
kejyun / AWS_S3_PHP_SDK_get_bucket.php
Created August 2, 2012 08:03
AWS取得容器清單
<?php
/*
* 取得容器清單
*/
$s3 = new AmazonS3();
$response = $s3->get_bucket_list();
print_r($response);
?>
@kejyun
kejyun / AWS_S3_PHP_SDK_upload_file.php
Created August 2, 2012 08:05
上傳檔案至AWS S3容器中
<?php
/*
* 上傳檔案至S3容器中
*/
$bucket = "kejyun-test"; //容器名稱
$s3_remote = array(
"filename" => "S3.txt", //檔案名稱
"dir" => "/", //檔案路徑
"file_privilege"=> AmazonS3::ACL_PUBLIC, //檔案存取權限
"contentType" => "text/plain", //檔案mime type
@kejyun
kejyun / AWS_S3_PHP_SDK_list_all_bucket_detail.php
Created August 2, 2012 08:06
列出容器所有物件(詳細)
<?php
/*
* 列出容器所有物件(詳細)
*/
$bucket = "kejyun-test"; //容器名稱
$s3 = new AmazonS3();
$response = $s3->list_objects($bucket);
print_r($response);
?>
@kejyun
kejyun / aws_s3_list_bucket_file.php
Created August 2, 2012 08:10
列出AWS容器檔案URL
<?php
/*
* 列出容器檔案URL
*/
$bucket = "kejyun-test"; //容器名稱
$s3_filepath = "/S3.txt";
$s3 = new AmazonS3();
$response = $s3->get_object_url($bucket);
print_r($response);
?>
@kejyun
kejyun / AWS_S3_PHP_SDK_list_bucket_object_simple_info.php
Created August 2, 2012 08:11
列出AWS容器所有物件(簡化)
<?php
/*
* 列出容器所有物件(簡化)
*/
$bucket = "kejyun-test"; //容器名稱
$s3 = new AmazonS3();
$response = $s3->get_object_list($bucket);
print_r($response);
?>
@kejyun
kejyun / AWS_S3_PHP_SDK_list_bucket_object_complex_info.php
Created August 2, 2012 08:12
列出容器所有物件(詳細)
<?php
/*
* 列出容器所有物件(詳細)
*/
$bucket = "kejyun-test"; //容器名稱
$s3 = new AmazonS3();
$response = $s3->list_objects($bucket);
print_r($response);
?>