提问人:Limone 提问时间:10/30/2023 更新时间:10/30/2023 访问量:23
使用 python-gitlab 将图片推送到 gitlab
Pushing picture to gitlab with python-gitlab
问:
我正在尝试将 jpg 图片推送到带有 .我的代码如下所示python-gitlab
gl = gitlab.Gitlab(GITLAB_URL, PRIVATE_TOKEN)
project = gl.projects.get(PROJECT_ID)
with open(file_path, 'rb') as f:
file_content = f.read()
branch = project.branches.get('main')
project.files.create(
{
'file_path': f"{REPOSITORY_PATH}/{PATH_IN_REPO}",
'branch': branch.name,
'content': file_content,
'commit_message': commit_message
}
)
具有(希望)变量的明显含义。我收到错误
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
我怀疑这与我打开jpg文件的方式有关。提示?
答: 暂无答案
评论
file_content.encode("base64")
encoding: base64