【问题标题】:Gitlab rest api file content "Invalid character in input stream." bashGitlab rest api 文件内容“输入流中的无效字符”。重击
【发布时间】:2021-11-01 03:58:45
【问题描述】:

我花了半个小时弄清楚为什么 base64 解码不起作用。

场景:

使用curl 从 Gitlab 读取文件内容并解码 base64 字符串。

这样做:

curl --request GET --header "PRIVATE-TOKEN: ${TOKEN}" "https://gitlab.example.com/api/v4/projects/123/repository/files/README%2Emd | jq '.content' | base64 -d

输出

Invalid character in input stream.

【问题讨论】:

    标签: curl gitlab base64


    【解决方案1】:

    原因:jq添加的引号。

    修复:

    https://gitlab.example.com/api/v4/projects/123/repository/files/README%2Emd | jq -r '.content' | base64 -d
    

    -r 原始输出标志

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-12-14
      • 2016-12-30
      • 2018-10-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多