Skip to content

Instantly share code, notes, and snippets.

@wokamoto
Created February 18, 2013 14:47
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wokamoto/4977932 to your computer and use it in GitHub Desktop.
Save wokamoto/4977932 to your computer and use it in GitHub Desktop.
[PHP][AWS] S3 オブジェクトの存在確認
<?php
require_once("aws.phar");
use Aws\Common\Aws;
use Aws\Common\Enum\Region;
use Aws\S3\Enum\CannedAcl;
use Aws\S3\Exception\S3Exception;
$s3 = Aws::factory(array(
'key' => $access_key,
'secret' => $secret_key,
'region' => Region::AP_NORTHEAST_1,
))->get('s3');
$s3->doesObjectExist($bucket, $key);
@kei161220
Copy link

doesObjectExistを使うと存在していてもfalseになる場合があります。
listObjectsのほうがいいかと

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment