Add File wrapped in Directory
cbluth opened this issue · comments
would it be possible to add a file wrapped in a directory with this library?
No, but I'm sure it is not too difficult to create the wrapping node and add that as well:
https://godoc.org/github.com/ipfs/go-unixfs#EmptyDirNode
https://godoc.org/github.com/ipfs/go-merkledag#ProtoNode.AddRawLink
i have an issue here: distributed-mind/pagesaver#2
i would like to move my project to ipfslite, but i would like to specify filenames of the files i add to ipfs
@cbluth I am saying that your problem is easily solvable outside ipfs-lite. And that I would start by trying something like:
// peer is the ipfs-lite peer instance
node := peer.AddFile(...) // add the file
emptyDir := unixfs.EmptyDirNode()
emptyDir.AddNodeLink("YOUR FILE NAME", node)
peer.Add(emptyDir) // add the wrapping folder
// emptyDir.Cid() should be the cid of the wrapping folder.