Uploading file using the REST API with HttpURLConnection
Hi, I'm using the acs-deployment 7.2.0 (the docker deployment) and I would like to upload a file using the REST APIs with Java HttpURLConnection, so by explicitly doing the POST (at the moment I cannot use the ReST API Java Wrapper Extension Point). From https://docs.alfresco.com/content-services/latest/develop/rest-api-guide/folders-files/#uploadfile I see the curl example, but I could not "translate" it in Java (I had no problem with the POST using the alfresco/api/-default-/public/authentication/versions/1/tickets call). I do not know how to deal with the various "-F" parameters and on how to pass the content of the file itself.
Has anyone use the direct REST APIs to upload a file in ACS? Could you please provide me a simple example on how to do it?
Following the link you provided, I was able to make it work with CloseableHttpClient + HttpPost + MultipartEntityBuilder classes. I'm still not able to make it work with the HttpURLConnection (I get a 400 response), but at least I know it can work with plain Java calls using the REST APIs.
The working code (so it could be useful for anyone who has the same issue) is: