Upload file by HTTP POST

前端 未结 1 1353
孤城傲影
孤城傲影 2021-01-07 05:46

I want to upload a file (an image specifically) to a REST Server using HTTP POST. I have already imported/add to build path httpmime-4.3.1.jar and

相关标签:
1条回答
  • 2021-01-07 05:58

    You seem to be missing a dependency.

    I have httpclient-4.2.5, httpcleint-cache-4.2.5, httpcore-4.2.4 and httpmime-4.2.5 with commons-lang3-3.1 and commons-logging-1.1.2 jars in my class path.

    I also use entity.addPart(formFieldName, new FileBody(file, "image/jpeg")); instead of using the header property.

    Take a look at Internet media type for more details

    0 讨论(0)
提交回复
热议问题