以下の内容はhttps://anton0825.hatenablog.com/entry/2016/08/26/000000より取得しました。


S3にファイルがあるかどうかを判定する

以下の関数で判定できる。

import boto3
import botocore
BUCKET = "バケット名"

def exist_file_in_s3(key):
    s3 = boto3.resource('s3')
    try:
        s3.Object(BUCKET, key).load()
    except botocore.exceptions.ClientError as e:
        if e.response['Error']['Code'] == "404":
            return False
        else:
            # 予期せぬエラーのため処理を終了
            raise
    else:
        return True

このぐらいはboto3の関数でできるだろと思ったけど、自分で実装するのか。。

参考:

stackoverflow.com




以上の内容はhttps://anton0825.hatenablog.com/entry/2016/08/26/000000より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14