【问题标题】:curl command line help for File upload文件上传的 curl 命令行帮助
【发布时间】:2014-08-24 02:01:12
【问题描述】:

我有一个基于 Jersey 的 REST API,它的签名看起来像这样

@POST
    @Path("{businessId}/logo/add/")
    @Consumes(MediaType.MULTIPART_FORM_DATA)
    @Produces(MediaType.TEXT_PLAIN)
    public Response uploadLogo(
        @PathParam("businessId") String businessId,
        FormDataMultiPart form
    ) {
......

我尝试了几个 curl 命令行以尝试使用 REST api 上传图像文件。但我似乎无法让它工作。我收到 415。我了解 415 错误代码,但我不知道发生了什么。我的请求中的 Content-Type 是正确的( multipart/form-data )

curl -i -X POST -F "imageFile=./image.jpg" http://myserver.com:8080/admin/02D0828864100000000B28C545B728F4/icon/add -v

POST /admin/02D0828864100000000B28C545B728F4/icon/add HTTP/1.1 用户代理:curl/7.30.0 主机:我的服务器:8080 接受:/ 内容长度:176 期望:100-继续 内容类型:multipart/form-data;边界=----------------------------c3081bfebd64

< HTTP/1.1 100 Continue
HTTP/1.1 100 Continue
< HTTP/1.1 415 Unsupported Media Type
HTTP/1.1 415 Unsupported Media Type
< Content-Length: 0
Content-Length: 0
* Server Jetty(9.1.z-SNAPSHOT) is not blacklisted
< Server: Jetty(9.1.z-SNAPSHOT)
Server: Jetty(9.1.z-SNAPSHOT)

* HTTP error before end of send, stop sending
< 
* Closing connection 0

【问题讨论】:

  • 同样的问题,你解决了吗?

标签: curl jersey


【解决方案1】:

你尝试过内容类型

curl -H "Content-Type:multipart/form-data" -i -X POST -F "imageFile=./image.jpg" http://myserver.com:8080/admin/02D0828864100000000B28C545B728F4/icon/add -v

?

【讨论】:

    猜你喜欢
    • 2011-05-23
    • 2017-07-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-02
    • 1970-01-01
    • 1970-01-01
    • 2016-05-04
    相关资源
    最近更新 更多