猿问

python boto3,上传文件到s3返回False但没有例外

try:

        

        if s3.meta.client.upload_file(fileLocation, bucket_name, objectName) is True:

            print("Upload log file to s3 bucket")

        else:

            print('Upload file to s3 bucket failed')

            return False

    except s3.exceptions:

        print("known error occured")

    except ClientError as e:

        print("Unexpected error: %s" % e)

我运行这段代码,但随后它打印出来Upload file to s3 bucket failed,没有发生异常,所以我不知道为什么它失败了。自从我从所有现有存储桶列表中获取了存储桶名称以来,s3 存储桶就存在了。


绝地无双
浏览 1627回答 1
1回答

天涯尽头无女友

s3.meta.client.upload_file根据文档,不会返回任何内容,因此您已经返回了,None并且它落入了其他内容,您检查过 S3 中的该文件吗?另外,请检查您的路径中是否有斜杠 (/),您的文件可能会以存储桶中的新冠文件夹“uploads”结尾。
随时随地看视频慕课网APP

相关分类

Python
我要回答