ipfs-shipyard / java-ipfs-http-client

A Java implementation of the HTTP IPFS API
MIT License
536 stars 244 forks source link

上传返回路径 #233

Open NewStartN opened 4 months ago

NewStartN commented 4 months ago

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

odisseus commented 3 months ago

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.