ipfs-shipyard / java-ipfs-http-client

A Java implementation of the HTTP IPFS API
MIT License
538 stars 243 forks source link

How to read the content of a file? #180

Closed QAInsights closed 3 years ago

QAInsights commented 3 years ago

I am trying to implement IPFS in JMeter. I followed the steps in the README.md. But the below line is not showing up the file content. Could you please guide me?

Multihash filePointer = Multihash.fromBase58("QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB");
byte[] fileContents = ipfs.cat(filePointer);
Clay-Ferguson commented 3 years ago

you just need to convert the byte array to a string.

String s = new String(bytes, StandardCharsets.UTF_8);
QAInsights commented 3 years ago

Thanks @Clay-Ferguson 🙏