i have a Problem with IPFS and Java. There are many Examples in the Internet but they aren't work anymore, cause GET is not longer supportet by IPFS. The Dependencies are included in pom.xml. So here is the Problem. I tried with POST Rest, but still this Error. Do you know how to fix this with POST in Java?
IPFS ipfs = new IPFS("/ip4/127.0.0.1/tcp/5001");
@POST
@Path("/file2IPFS")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response test(@FormDataParam("file") InputStream uploadInputStream) throws IOException {
//create File from Inputstream is normally included but for Example with Hello.txt
ipfs.refs.local();
NamedStreamable.FileWrapper file = new NamedStreamable.FileWrapper(new File("hello.txt"));
MerkleNode addResult = ipfs.add(file).get(0);
return Response.status(200).entity("Passt").build();
}
This is the Code Snipptet. This Method is part of an Rest-Webservice.
java.lang.RuntimeException: IOException contacting IPFS daemon.
Trailer: null 405 - Method Not Allowed
at io.ipfs.api.IPFS.get(IPFS.java:592)
at io.ipfs.api.IPFS.retrieve(IPFS.java:571)
at io.ipfs.api.IPFS.retrieveAndParse(IPFS.java:553)
at io.ipfs.api.IPFS.version(IPFS.java:501)
at io.ipfs.api.IPFS.<init>(IPFS.java:61)
at io.ipfs.api.IPFS.<init>(IPFS.java:52)
at io.ipfs.api.IPFS.<init>(IPFS.java:48)
You should use the older IPFS version.