I have a FileOutputStream and am trying to get the contents of this file on a remote server. The server has an API to which I should POST the contents of the file (which is an .xls file). The API requires me to POST the data to its API URL and set the ContentType to that of an .xls file in this case.
The code is something as follows:
try {
outputFile = new FileOutputStream("myfile.xls");
}
catch (FileNotFoundException e) {
e.printStackTrace(System.err);
}
handle.sendRequest("https://server/API/file/id", "POST", "application/vnd.ms-excel", data);
How can I send the data of the file in the stream to the server?