ipfs-shipyard / java-ipfs-http-client

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

[help wanted]difference between "public ByteArrayWrapper(byte[] data)" and "public ByteArrayWrapper(String name, byte[] data)" #134

Closed CoreyLin closed 1 year ago

CoreyLin commented 5 years ago

I noticed that ByteArrayWrapper has three constructors, two of which take "name" as the first argument, so what does "name" mean from IPFS business point of view? In other words, before calling ipfs.add, what's the difference between "public ByteArrayWrapper(byte[] data)" and "public ByteArrayWrapper(String name, byte[] data)"? Thanks very much!

odisseus commented 4 years ago

This constructor allows you to construct a NamedStreamable that looks like a file (complete with a file name) without accessing the file system. If this "file" gets added into IPFS as part of a DirWrapper (which doesn't have to correspond to a real directory either), its name will be stored in the data block.