Я получаю ошибку 404 при загрузке файла на мой сервер Ubuntu.
public class Test {
public static void main(String[] args) throws ClientProtocolException, IOException {
// TODO Auto-generated \ stub
CloseableHttpClient httpClient = HttpClients.createDefault();
UsernamePasswordCredentials creds = new UsernamePasswordCredentials("user", "password");
System.out.println(creds.getUserPrincipal().getName());
System.out.println(creds.getPassword());
HttpPost uploadFile = new HttpPost("http://10.0.0.45/home");
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.addTextBody("field1", "yes", ContentType.TEXT_PLAIN);
// This attaches the file to the POST:
File f = new File("D:\\chinta\\abc.txt");
builder.addBinaryBody(
"file",
new FileInputStream(f),
ContentType.APPLICATION_OCTET_STREAM,
f.getName()
);
HttpEntity multipart = builder.build();
uploadFile.setEntity(multipart);
CloseableHttpResponse response = httpClient.execute(uploadFile);
System.out.println("=s========================"+response.getStatusLine());
HttpEntity responseEntity = response.getEntity();
}
}
Я получаю ошибку 404 в response.getstatus.