S3Cmd不适用于S3 Ninja

时间:2016-07-18 10:55:13

标签: python amazon-web-services amazon-s3 s3cmd

我试图使用我的本地s3ninja和s3cmd。 每个命令如:s3cmd ls s3://test都会抛出相同的异常。

s3cfg似乎没问题,被叫端点也是正确的。

是否有人能够将s3ninja与s3cmd一起使用?

PS:我知道S3并不昂贵,而且有很多更好的方法来测试S3。我出于其他原因需要S3 Ninja。

以下是调试信息:

DEBUG: ConfigParser: Reading file '/Users/daniel/.s3cfg'
DEBUG: ConfigParser: access_key->AK...17_chars...E
DEBUG: ConfigParser: access_token->
DEBUG: ConfigParser: add_encoding_exts->
DEBUG: ConfigParser: add_headers->
DEBUG: ConfigParser: bucket_location->US
DEBUG: ConfigParser: ca_certs_file->
DEBUG: ConfigParser: cache_file->
DEBUG: ConfigParser: check_ssl_certificate->True
DEBUG: ConfigParser: check_ssl_hostname->True
DEBUG: ConfigParser: cloudfront_host->cloudfront.amazonaws.com
DEBUG: ConfigParser: default_mime_type->binary/octet-stream
DEBUG: ConfigParser: delay_updates->False
DEBUG: ConfigParser: delete_after->False
DEBUG: ConfigParser: delete_after_fetch->False
DEBUG: ConfigParser: delete_removed->False
DEBUG: ConfigParser: dry_run->False
DEBUG: ConfigParser: enable_multipart->True
DEBUG: ConfigParser: encoding->UTF-8
DEBUG: ConfigParser: encrypt->False
DEBUG: ConfigParser: expiry_date->
DEBUG: ConfigParser: expiry_days->
DEBUG: ConfigParser: expiry_prefix->
DEBUG: ConfigParser: follow_symlinks->False
DEBUG: ConfigParser: force->False
DEBUG: ConfigParser: get_continue->False
DEBUG: ConfigParser: gpg_command->None
DEBUG: ConfigParser: gpg_decrypt->%(gpg_command)s -d --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)s
DEBUG: ConfigParser: gpg_encrypt->%(gpg_command)s -c --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)s
DEBUG: ConfigParser: gpg_passphrase->...-3_chars...
DEBUG: ConfigParser: guess_mime_type->True
DEBUG: ConfigParser: host_base->s3.mylocalaws.com:9444/s3
DEBUG: ConfigParser: host_bucket->s3.mylocalaws.com:9444/s3/%(bucket)s
DEBUG: ConfigParser: human_readable_sizes->False
DEBUG: ConfigParser: invalidate_default_index_on_cf->False
DEBUG: ConfigParser: invalidate_default_index_root_on_cf->True
DEBUG: ConfigParser: invalidate_on_cf->False
DEBUG: ConfigParser: kms_key->
DEBUG: ConfigParser: limitrate->0
DEBUG: ConfigParser: list_md5->False
DEBUG: ConfigParser: log_target_prefix->
DEBUG: ConfigParser: long_listing->False
DEBUG: ConfigParser: max_delete->-1
DEBUG: ConfigParser: mime_type->
DEBUG: ConfigParser: multipart_chunk_size_mb->15
DEBUG: ConfigParser: preserve_attrs->True
DEBUG: ConfigParser: progress_meter->True
DEBUG: ConfigParser: proxy_host->
DEBUG: ConfigParser: proxy_port->0
DEBUG: ConfigParser: put_continue->False
DEBUG: ConfigParser: recursive->False
DEBUG: ConfigParser: recv_chunk->65536
DEBUG: ConfigParser: reduced_redundancy->False
DEBUG: ConfigParser: requester_pays->False
DEBUG: ConfigParser: restore_days->1
DEBUG: ConfigParser: secret_key->wJ...37_chars...Y
DEBUG: ConfigParser: send_chunk->65536
DEBUG: ConfigParser: server_side_encryption->False
DEBUG: ConfigParser: signature_v2->False
DEBUG: ConfigParser: simpledb_host->sdb.amazonaws.com
DEBUG: ConfigParser: skip_existing->False
DEBUG: ConfigParser: socket_timeout->300
DEBUG: ConfigParser: stop_on_error->False
DEBUG: ConfigParser: storage_class->
DEBUG: ConfigParser: urlencoding_mode->normal
DEBUG: ConfigParser: use_https->False
DEBUG: ConfigParser: use_mime_magic->True
DEBUG: ConfigParser: verbosity->WARNING
DEBUG: ConfigParser: website_endpoint->http://%(bucket)s.s3-website-%(location)s.amazonaws.com/
DEBUG: ConfigParser: website_error->
DEBUG: ConfigParser: website_index->index.html
DEBUG: Updating Config.Config cache_file -> 
DEBUG: Updating Config.Config follow_symlinks -> False
DEBUG: Updating Config.Config verbosity -> 10
DEBUG: Unicodising 'ls' using UTF-8
DEBUG: Unicodising 's3://test' using UTF-8
DEBUG: Command: ls
DEBUG: Bucket 's3://test':
DEBUG: CreateRequest: resource[uri]=/
DEBUG: Using signature v4
DEBUG: get_hostname(test): s3.mylocalaws.com:9444/s3/test
DEBUG: canonical_headers = host:s3.mylocalaws.com:9444/s3/test
x-amz-content-sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
x-amz-date:20160718T104632Z

DEBUG: Canonical Request:
GET
/
delimiter=%2F
host:s3.mylocalaws.com:9444/s3/test
x-amz-content-sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
x-amz-date:20160718T104632Z

host;x-amz-content-sha256;x-amz-date
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
----------------------
DEBUG: signature-v4 headers: {'x-amz-content-sha256': 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 'Authorization': 'AWS4-HMAC-SHA256 Credential=AKIAIOSFODNN7EXAMPLE/20160718/US/s3/aws4_request,SignedHeaders=host;x-amz-content-sha256;x-amz-date,Signature=f58c63587c00d0c01122db06cf0b8a7376a2484b0572db3c562edddbd6d2fdb1', 'x-amz-date': '20160718T104632Z'}
DEBUG: Processing request, please wait...
DEBUG: get_hostname(test): s3.mylocalaws.com:9444/s3/test
DEBUG: ConnMan.get(): creating new connection: http://s3.mylocalaws.com:9444/s3/test

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    An unexpected error has occurred.
  Please try reproducing the error using
  the latest s3cmd code from the git master
  branch found at:
    https://github.com/s3tools/s3cmd
  and have a look at the known issues list:
    https://github.com/s3tools/s3cmd/wiki/Common-known-issues-and-their-solutions
  If the error persists, please report the
  following lines (removing any private
  info as necessary) to:
   s3tools-bugs@lists.sourceforge.net

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

DEBUG: Unicodising '/usr/local/bin/s3cmd' using UTF-8
DEBUG: Unicodising 'ls' using UTF-8
DEBUG: Unicodising 's3://test' using UTF-8
DEBUG: Unicodising '--debug' using UTF-8
Invoked as: /usr/local/bin/s3cmd ls s3://test --debug
Problem: UnboundLocalError: local variable 'conn' referenced before assignment
S3cmd:   1.6.0
python:   2.7.11 (default, Jan 22 2016, 08:29:18) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)]
environment LANG=de_DE.UTF-8

Traceback (most recent call last):
  File "/usr/local/bin/s3cmd", line 2805, in <module>
    rc = main()
  File "/usr/local/bin/s3cmd", line 2713, in main
    rc = cmd_func(args)
  File "/usr/local/bin/s3cmd", line 120, in cmd_ls
    subcmd_bucket_list(s3, uri)
  File "/usr/local/bin/s3cmd", line 153, in subcmd_bucket_list
    response = s3.bucket_list(bucket, prefix = prefix)
  File "/usr/local/lib/python2.7/site-packages/S3/S3.py", line 293, in bucket_list
    for dirs, objects in self.bucket_list_streaming(bucket, prefix, recursive, uri_params):
  File "/usr/local/lib/python2.7/site-packages/S3/S3.py", line 320, in bucket_list_streaming
    response = self.bucket_list_noparse(bucket, prefix, recursive, uri_params)
  File "/usr/local/lib/python2.7/site-packages/S3/S3.py", line 339, in bucket_list_noparse
    response = self.send_request(request)
  File "/usr/local/lib/python2.7/site-packages/S3/S3.py", line 1084, in send_request
    conn.counter = ConnMan.conn_max_counter
UnboundLocalError: local variable 'conn' referenced before assignment

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    An unexpected error has occurred.
  Please try reproducing the error using
  the latest s3cmd code from the git master
  branch found at:
    https://github.com/s3tools/s3cmd
  and have a look at the known issues list:
    https://github.com/s3tools/s3cmd/wiki/Common-known-issues-and-their-solutions
  If the error persists, please report the
  above lines (removing any private
  info as necessary) to:
   s3tools-bugs@lists.sourceforge.net
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

3 个答案:

答案 0 :(得分:3)

s3cmd目前迫使api出现在/。另一方面,s3ninja不允许将其设置为&#39; /&#39;。我已经向s3cmd提出要处理的功能(PR 781) - 您可以自己修补s3cmd。

另一种解决方案是设置一些代理,例如nginx /&gt; /s3

答案 1 :(得分:1)

This is my nginx proxy configuration that works perfectly with s3cmd and S3 Ninja.

server {
      listen 80;
      server_name s3.eu-central-1.amazonaws.com;

      location / {
          proxy_pass         http://127.0.0.1:9444/s3/;
      }
  }

With the following host configuration:

host_base = s3.eu-central-1.amazonaws.com
host_bucket = s3.eu-central-1.amazonaws.com

And you need to add an entry to /etc/hosts:

127.0.0.1  s3.eu-central-1.amazonaws.com

This also works with a reverse proxy and https.

答案 2 :(得分:0)

S3cmd使用AWS端点,但尚未准备好使用与S3兼容的接口。尝试“获取存储桶位置”时失败。

--bucket-location=BUCKET_LOCATION
     

数据中心创建存储桶。截至目前,数据中心为:美国   (默认),EU,us-west-1和ap-southeast-1

http://linux.die.net/man/1/s3cmd