boto S3ResponseError:400错误请求 [英] boto S3ResponseError: 400 Bad Request

查看:873
本文介绍了boto S3ResponseError:400错误请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在AWS上的EC2 Ubuntu上部署我的Django应用程序。



我完成了所有需要的工作,但连接到boto。



在我的 settings.py

  AWS_ACCESS_KEY ='AWS_ACCESS_KEY'
AWS_SECRET_ACCESS_KEY ='AWS_SECRET_ACCESS_KEY'
AWS_STORAGE_BUCKET_NAME ='BUCKET-s3'
AWS_QUERYSTRING_AUTH = False
S3_URL ='https://s3.ap-northeast-2 .amazonaws.com /%s'%AWS_STORAGE_BUCKET_NAME

DEFAULT_FILE_STORAGE ='PROJECT.s3utils.MediaS3BotoStorage'
STATICFILES_STORAGE ='PROJECT.s3utils.StaticRootS3BotoStorage'
MEDIA_URL = S3_URL +'/媒体/'
STATIC_URL = S3_URL +'/ static /'

MEDIA_ROOT = MEDIA_URL
STATIC_ROOT = STATIC_URL

'PROJECT.s3utils.py'在下面:

  from storages.backends.s3boto import S3BotoStorage 
StaticRootS3BotoStorage = lambda:S 3BotoStorage(location ='static')#s3目录名
class MediaS3BotoStorage(S3BotoStorage):
location ='media'

最后,我需要设置连接boto的配置文件。



没有任何东西,当我命令'python manage.py collectstatic ',错误显示此消息:


boto.exception.NoAuthHandlerFound:没有处理程序准备好
验证。检查1个处理程序。 ['HmacAuthV1Handler']检查
您的凭据


所以我添加了配置文件在 '〜/ .boto' 如下:

  [凭据] 
AWS_ACCESS_KEY_ID = AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY = AWS_SECRET_ACCESS_KEY

创建后配置文件〜/ .boto,我没有命令'python manage.py collectstatic'



我有一个错误:



< blockquote>

boto.exception.S3ResponseError:S3ResponseError:400错误请求


我做的是跟随boto文件:



有没有什么我现在失踪?

解决方案

〜/ .boto em>

  [凭据] 
aws_access_key_id = aws_access_key_id
aws_secret_access_key = aws_secret_access_key
[s3]
host = s3.ap-northeast-2.amazonaws.com
aws_access_key_id = aws_access_key_id
aws_secret_access_key = aws_secret_access_key

使用〜/ .boto文件以上


I'm deploying my Django application on Ubuntu of EC2 on AWS.

I finished all the jobs needed but connecting to boto.

In my settings.py

AWS_ACCESS_KEY = 'AWS_ACCESS_KEY'
AWS_SECRET_ACCESS_KEY = 'AWS_SECRET_ACCESS_KEY'
AWS_STORAGE_BUCKET_NAME = 'BUCKET-s3'
AWS_QUERYSTRING_AUTH = False
S3_URL = 'https://s3.ap-northeast-2.amazonaws.com/%s' % AWS_STORAGE_BUCKET_NAME

DEFAULT_FILE_STORAGE = 'PROJECT.s3utils.MediaS3BotoStorage'
STATICFILES_STORAGE = 'PROJECT.s3utils.StaticRootS3BotoStorage'
MEDIA_URL = S3_URL + '/media/'
STATIC_URL = S3_URL + '/static/'

MEDIA_ROOT = MEDIA_URL
STATIC_ROOT = STATIC_URL

'PROJECT.s3utils.py' is below:

from storages.backends.s3boto import S3BotoStorage
StaticRootS3BotoStorage = lambda: S3BotoStorage(location='static') # s3 directory name
class MediaS3BotoStorage(S3BotoStorage):
    location = 'media'

Finally, I need to set up configuration file for connecting boto.

Without anything, when I command 'python manage.py collectstatic' , the error shows this message :

boto.exception.NoAuthHandlerFound: No handler was ready to authenticate. 1 handlers were checked. ['HmacAuthV1Handler'] Check your credentials

So I did add configuration file at '~/.boto' as below:

[Credentials]
AWS_ACCESS_KEY_ID=AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY=AWS_SECRET_ACCESS_KEY

After creating configuration file ~/.boto, I did command 'python manage.py collectstatic'

I got an error :

boto.exception.S3ResponseError: S3ResponseError: 400 Bad Request

What I do is following the boto document : http://boto.cloudhackers.com/en/latest/getting_started.html

Is there anything I am missing now?

解决方案

~/.boto

[Credentials]
aws_access_key_id = aws_access_key_id
aws_secret_access_key = aws_secret_access_key
[s3]
host=s3.ap-northeast-2.amazonaws.com
aws_access_key_id = aws_access_key_id
aws_secret_access_key = aws_secret_access_key

It's working with ~/.boto file above

这篇关于boto S3ResponseError:400错误请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆