java-ipfs-http-client icon indicating copy to clipboard operation
java-ipfs-http-client copied to clipboard

上传返回路径

Open NewStartN opened this issue 1 year ago • 1 comments

怎么在返回的访问路径上加上文件名称啊,例如http://127.0.0.1:8080/ipfs/QmTGK9aXJsgw53eSa4CVG4zZSiDrK2mQg8Q5nVNtiYuFUR/文件名称

NewStartN avatar Mar 26 '24 03:03 NewStartN

If you want the file name to be stored in the DAG, you have to enclose your file within a directory. To do that, call setWrapWithDirectory() on your AddArgs.Builder:

AddArgs args = AddArgs.Builder.newInstance()
    .setWrapWithDirectory()
    .build();
List<MerkleNode> tree = ipfs.add(file, args);

See the documentation for the Kubo RPC API.

Alternatively, just append the filename you want to the end of your file URL: http://[gateway]/ipfs/[hash]?filename=[your file name]

See the documentation for the HTTP gateway.

odisseus avatar Apr 24 '24 13:04 odisseus