S3cmd signurl中文支持问题怎么解决

发布时间:2021-12-30 16:19:39 作者:iii
来源:亿速云 阅读:179

本篇内容主要讲解“S3cmd signurl中文支持问题怎么解决”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“S3cmd signurl中文支持问题怎么解决”吧!

S3cmd signurl中文支持问题

s3cmd --version
s3cmd version 1.6.1

s3cmd signurl s3://s3demo/ceph知识树.png +200

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    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


You have encountered a UnicodeEncodeError.  Your environment
variable LANG=zh_CN.UTF-8 may not specify a Unicode encoding (e.g. UTF-8).
Please set LANG=en_US.UTF-8 or similar in your environment before
invoking s3cmd.

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

Invoked as: /usr/local/bin/s3cmd signurl s3://hxs1-s3soft/ceph知识树.png +200
Problem: UnicodeEncodeError: 'ascii' codec can't encode characters in position 31-33: ordinal not in range(128)
S3cmd:   1.6.1
python:   2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)]
environment LANG=zh_CN.UTF-8

Traceback (most recent call last):
  File "/usr/local/bin/s3cmd", line 2923, in <module>
    rc = main()
  File "/usr/local/bin/s3cmd", line 2843, in main
    rc = cmd_func(args)
  File "/usr/local/bin/s3cmd", line 2017, in cmd_signurl
    debug("url to sign: %r" % url_to_sign)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 31-33: ordinal not in range(128)

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    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
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

在s3cmd源码文件中添加下面两行解决

reload(sys) 
sys.setdefaultencoding('utf-8')

patch最终效果

 2894 if __name__ == '__main__':
2895     try:
2896         ## Our modules
2897         ## Keep them in try/except block to
2898         ## detect any syntax errors in there
2899         reload(sys) #新加
2900         sys.setdefaultencoding('utf-8') #新加
2901         from S3.ExitCodes import *
2902         from S3.Exceptions import *

到此,相信大家对“S3cmd signurl中文支持问题怎么解决”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

推荐阅读:
  1. 在Linux上如何安装s3cmd
  2. 如何打造基于s3cmd的短地址服务

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

s3cmd

上一篇:tcpdump的语法及参数有哪些

下一篇:如何进行packetshaper产品学习

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》