小编Her*_*man的帖子

为什么git log显示我的密码?

当我输入git log生成的提交列表时,在我的用户名后面括号<>中显示我的密码,如下所示:

commit 5ff14f929e2244f388a41b6f711e7b9b58c57cb2
Author: herman <MyPassw0rd>
Date:   Wed Aug 29 10:00:39 2018 +0200

initial commit 
Run Code Online (Sandbox Code Playgroud)

为什么会这样做,我该如何解决?

git password-protection

1
推荐指数
1
解决办法
538
查看次数

使用 Boto3 从内存上传文件到 S3

这个问题已经被问过很多次了,但我的情况却略有不同。我正在尝试创建一个 lambda 来生成 .html 文件并将其上传到 S3。当文件在磁盘上创建时它工作,然后我可以像这样上传它:

boto3.client('s3').upload_file('index.html', bucket_name, 'folder/index.html')
Run Code Online (Sandbox Code Playgroud)

所以现在我必须在内存中创建文件,为此我首先尝试了StringIO()。但是然后.upload_file抛出一个错误。

boto3.client('s3').upload_file(temp_file, bucket_name, 'folder/index.html')
ValueError: Filename must be a string`. 
Run Code Online (Sandbox Code Playgroud)

所以我尝试使用.upload_fileobj()但后来出现错误TypeError: a bytes-like object is required, not 'str'

所以我尝试使用Bytesio(),它希望我首先将 str 转换为字节,所以我做了:

temp_file = BytesIO()
temp_file.write(index_top.encode('utf-8'))
print(temp_file.getvalue())
boto3.client('s3').upload_file(temp_file, bucket_name, 'folder/index.html')
Run Code Online (Sandbox Code Playgroud)

但现在它只是上传一个空文件,尽管.getvalue()清楚地表明它确实有内容。

我究竟做错了什么?

amazon-s3 amazon-web-services python-3.x boto3

1
推荐指数
2
解决办法
1118
查看次数