My case similar to this post,
https://bbs.csdn.net/topics/390885581
CodePudding user response:
HttpClient=HttpClients. CreateDefault ();
HttpPost HttpPost=new HttpPost (url);
InputStream InputStream=new FileInputStream (filePath);
MultipartEntityBuilder builder=MultipartEntityBuilder. The create ();
Builder. SetCharset (Charset. Class.forname (" utf-8 "));
Builder. SetMode (HttpMultipartMode. BROWSER_COMPATIBLE);
Builder. AddBinaryBody (name, inputStream, ContentType. Create (" multipart/form - data ", Consts UTF_8), fileName);
This is the code I wrote, in the Windows environment, read the absolute path will be a problem, but the absolute path under Linux, will become the backslash backslash, thus path to find and get file