通过cURL发布zip文件将提供二进制输出

问题描述 投票:0回答:1

我正在使用虚拟化软件,该软件允许我通过POST请求更新正在运行的虚拟服务。通过Web浏览器中提供的UI完成发布请求后,该发布请求才起作用。它还在网页上生成curl命令。

curl -X POST "http://localhost:1505/lisa-virtualize-invoke/api/v3/vses/VSE/services/API_Test_22" -H  "accept: application/json" -H  "Content-Type: multipart/form-data" -F "deploy=true" -F "[email protected];type=application/x-zip-compressed"

但是,当我尝试在bash中使用提供的curl命令时,它不起作用。我需要能够对jenkinsfile使用curl。

我尝试了'inputFile1'的不同变体,例如:

-F "[email protected];type=application/x-zip-compressed"
-F "[email protected]"

在GitBash中,我得到了一个乱码的非ASCII字符作为输出。

在Ubuntu终端中,我收到另一个错误:

curl -X POST -H "authorization: Basic xxx"  "http://10.0.2.2:1505/lisa-virtualize-invoke/api/v3/vses/VSE/services/API_Test_22" -H  "accept: application/zip" -H  "Content-Type: multipart/form-data" -F "deploy=true" -F "inputFile1=@\"updateCustomer.zip\""
Warning: Binary output can mess up your terminal. Use "--output -" to tell 
Warning: curl to output it to your terminal anyway, or consider "--output 
Warning: <FILE>" to save to a file.

我在詹金斯的输出是:

+ curl -X POST -H authorization: Basic xxx http://10.0.2.2:1505/lisa-virtualize-invoke/api/v3/vses/VSE/services/API_Test_22 -H accept: application/zip -H Content-Type: multipart/form-data -F deploy=true -F [email protected]
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                             Dload  Upload   Total   Spent    Left  Speed

 0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 63261    0     0  100 63261      0  52325  0:00:01  0:00:01 --:--:-- 52325
100 63261    0     0  100 63261      0  28599  0:00:02  0:00:02 --:--:-- 28599
100 63261    0     0  100 63261      0  19682  0:00:03  0:00:03 --:--:-- 19689
100 63261    0     0  100 63261      0  15004  0:00:04  0:00:04 --:--:-- 15008
100 63261    0     0  100 63261      0  12121  0:00:05  0:00:05 --:--:-- 12121
100 63261    0     0  100 63261      0  10165  0:00:06  0:00:06 --:--:--     0
100 63971    0   710  100 63261    103   9220  0:00:06  0:00:06 --:--:--   152PK�S�N    .maraudit����n�q�w � �4���g���ؤ��(�T�l�o @�1r�~����} &-������U�ƨ���������>���������o�_��g��W�����?���_~�����?��7��~˟����7�����7����?���_�~�B��?��/b����2��h���C�!���������������/ ...
curl post zip multipartform-data binaryfiles
1个回答
0
投票

二进制输出是由-H“ accept:application / zip”引起的。用-H“ accept:application / json”替换后,我不再遇到这个问题。

© www.soinside.com 2019 - 2024. All rights reserved.