Closed jollycar closed 5 years ago
That's a reasonable feature request. I can add this to the next version.
Meanwhile, you can execute the following query:
public MetadataAndPayload getByHash(String hash) {
Query query = Query.newQuery().equals("_hash", hash);
Page<MetadataAndPayload> result = ipfsstore.searchAndFetch("documents", query, 0, 1);
if (result.getTotalElements() == 0) {
throw new NotFoundException("Document identified by hash " + hash + " not found.");
}
return result.getContent().get(0);
}
Fixed in 0.1.16
IPFSStore client = new IPFSStore("http://localhost:8040/", "myindex");
MetadataAndPayload result = client.getByHash("myindex", "QmYZdDyJYAj2jAXzt8ZYD13ApbAKohgUgrTi8KHTKycVZC");
Given I only have the IPFS hash of the file, I would like to get the MetadataAndPayload of this file. Right now this is only possible to do a search.
There already exist a method in IPFSStore.java to get the payload, but you need to know the id: public MetadataAndPayload getById(String indexName, String id)
Is it possible to add a method to get the MetadataAndPayload by hash?