本文介绍了获取boto.exception.S3ResponseError:S3ResponseError:上传文件时,403禁止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关于这个问题的一些其他问题:

There are a few other questions on this issue:

boto.exception.S3ResponseError: S3ResponseError:403禁止

S3ResponseError: S3ResponseError:403禁止

S3ResponseError: 403使用博托禁止

Python:亚马逊S3不能得到斗:说403禁止

不过,看来我可以有一个不同的问题(例如,时钟偏斜不是问题,我已经尝试设置验证=假,我相信我有因为试图伪造的密钥或秘密密钥正确的密钥和秘密密钥给了我不同的错误)。这里是我的脚本:

However, it seems I may be having a different problem (e.g., clock skew is not an issue and I already tried setting validate=False, and I believe I have the correct key and secret key because trying a bogus key or secret key gives me different errors). Here is my script:

import boto
import sys
from boto.s3.key import Key

BUCKET_NAME = sys.argv[1]
AWS_ACCESS_KEY_ID = sys.argv[2]
AWS_SECRET_ACCESS_KEY = sys.argv[3]

conn = boto.connect_s3(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
bucket = conn.get_bucket(BUCKET_NAME, validate=False)
k = Key(bucket)
k.key = 'barbaz'
k.set_contents_from_filename('/tmp/barbaz.txt')

和结果:

Traceback (most recent call last):
  File "/home/jonderry/sdmain/src/scripts/jenkins/upload_to_s3.py", line 16, in <module>
    k.set_contents_from_filename('/tmp/barbaz.txt')
  File "/usr/local/lib/python2.7/dist-packages/boto/s3/key.py", line 1360, in set_contents_from_filename
    encrypt_key=encrypt_key)
  File "/usr/local/lib/python2.7/dist-packages/boto/s3/key.py", line 1291, in set_contents_from_file
    chunked_transfer=chunked_transfer, size=size)
  File "/usr/local/lib/python2.7/dist-packages/boto/s3/key.py", line 748, in send_file
    chunked_transfer=chunked_transfer, size=size)
  File "/usr/local/lib/python2.7/dist-packages/boto/s3/key.py", line 949, in _send_file_internal
    query_args=query_args
  File "/usr/local/lib/python2.7/dist-packages/boto/s3/connection.py", line 664, in make_request
    retry_handler=retry_handler
  File "/usr/local/lib/python2.7/dist-packages/boto/connection.py", line 1068, in make_request
    retry_handler=retry_handler)
  File "/usr/local/lib/python2.7/dist-packages/boto/connection.py", line 939, in _mexe
    request.body, request.headers)
  File "/usr/local/lib/python2.7/dist-packages/boto/s3/key.py", line 882, in sender
    response.status, response.reason, body)
boto.exception.S3ResponseError: S3ResponseError: 403 Forbidden
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>***someRequestId***</RequestId><HostId>***someHostId</HostId></Error>

任何想法是什么问题,还是如何进一步诊断?

Any ideas what is the problem, or how to diagnose further?

推荐答案

看起来,你不必在这斗写的权利。什么是斗的政策?你能确保这IAM用户可以把这个桶?

It looks like that you do not have the right to write on this bucket. What is the bucket policy? Can you make sure that this IAM user can put on this bucket?

这篇关于获取boto.exception.S3ResponseError:S3ResponseError:上传文件时,403禁止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 11:28