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
提交
取消