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 存储桶就存在了。
1 回答

天涯尽头无女友
TA贡献1831条经验 获得超9个赞
s3.meta.client.upload_file
根据文档,不会返回任何内容,因此您已经返回了,None
并且它落入了其他内容,您检查过 S3 中的该文件吗?
另外,请检查您的路径中是否有斜杠 (/),您的文件可能会以存储桶中的新冠文件夹“uploads”结尾。
添加回答
举报
0/150
提交
取消