python-3.x - 尝试通过 Python Gitlab api 将 gz 文件上传到 Gitlab
问题描述
我正在尝试通过 python gitlab api 将 .gz 文件上传到 gitlab。但是,我发现这样做的唯一文档是通过创建文件。
https://python-gitlab.readthedocs.io/en/stable/gl_objects/projects.html#id7
我已经尝试过使用我的 gz 文件,但是我得到的错误代码是
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
f = project.files.create({'file_path': 'testfile.txt',
'branch': 'master',
'content': file_content,
'author_email': 'test@example.com',
'author_name': 'yourname',
'commit_message': 'Create testfile'})
我的预期结果是能够通过 API 或其他方法将 gz 文件上传到 Gitlab。
解决方案
我最终使用 paramiko 并通过该库进行连接。我最终使用 ssh.exec_command 并键入了所有命令,后跟 \n 以解决此问题。
推荐阅读
- python - 如何使用 Python 解码编码的电子邮件地址?
- node.js - 如何保存将命令的输出“npm run migrations”保存到变量中
- python - 无法在没有主键的情况下强制更新 save()
- python - 基于两个属性的 JSON 文件中的重复项
- node.js - Socket.io-redis 配置不起作用
- python - 这在技术上是列表理解吗?
- html - CSS Grid minmax with auto as min
- android - 夜间模式颜色值不适用于回收站视图项目
- python - CSS 文件(main.css)中的图像不使用 Flask 加载
- python - PermissionError:[Errno 13] 权限被拒绝:pyinstaller.exe/zipcodes windows 10