上传文件的 Curl URL 语法

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

我正在尝试通过使用curl 上传替换图片来替换NetBox 中的图片。我发现根据我使用的 URL 形式,我会收到不同的错误消息。

请注意,如果我使用 PUT 而不是 PATCH,我会收到相同的错误消息。

该文件只有 4Mb,位于当前目录中。

文件归我所有,并具有以下权限:-rwxrwxrwx

我尝试替换的文件在 NetBox 中的 object_id 为 3852。

这是我正在使用的curl命令:

curl \
 --request PATCH \
 https://my.netbox.com/api/extras/image-attachments/3852/ \
 --verbose \
 --cacert "mycert.pem" \
 --header "Content-Type: multipart/form-data" \
 --header "Authorization: Token mytoken" \
 --Form "content_type=dcim.rack" \
 --Form "object_id=3852" \
 --Form "name=replacement.jpg" \
 --Form "[email protected];type=image/jpg" \
 --Form "image_height=3024" \
 --Form "image_width=4032"

以下是我通过不同形式的 URL 收到的错误消息:

https://my.netbox.com/api/extras/image-attachments/3852/ 
 * We are completely uploaded and fine
 {"non_field_errors":["Invalid parent object: dcim | rack ID 3852"]}
https://my.netbox.com/api/extras/image-attachments/3852
 * We are completely uploaded and fine
 < HTTP/1.1 301 Moved Permanently
https://my.netbox.com/api/extras/image-attachments/
   <p>
     There was a problem with your request. Please contact an administrator.
   </p>
 
 <hr />
 <p>
   The complete exception is provided below:
 </p>
 <pre class="block"><strong>&lt;class &#x27;AttributeError&#x27;&gt;</strong><br />
 &#x27;str&#x27; object has no attribute &#x27;pop&#x27;
https://my.netbox.com/api/extras/image-attachments
 * We are completely uploaded and fine
 < HTTP/1.1 301 Moved Permanently

这些似乎都没有真正上传文件,即使有消息:我们已完全上传并且很好

我应该如何格式化 URL 才能实现此功能?

curl url syntax upload netbox
1个回答
0
投票

21.36

4G

facebook.com/asrulheidi

科切帕利布

39

儿童扫描电镜

科切帕利布

380 个朋友

添加好友

留言

Direktur Utama di PT。 CINTA SEJATI 在 Pemilik Toko Dheris 花

在 tukang semir spatu 工作

去了SMA Negeri 7 Surabaya

住在印度尼西亚苏拉威西南部布卢库巴

来自印度尼西亚苏拉威西南部布卢库巴

了解更多关于科切的信息

埃里安德

f

全部

在应用程序上获得最佳体验

X

获取

f

...

X

+

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