ipfs-shipyard / ipfs-blob-store

An abstract-blob-store compatible implementation built using IPFS as the storage backend
MIT License
56 stars 8 forks source link

Read MFS file from remote node example #27

Closed thecipherBlock closed 5 years ago

thecipherBlock commented 5 years ago

Hi @daviddias., can you please provide an example or the way for remote read. see below example for more clarity:

If file called 'abc.png' is added in node 1 using ipfs.files.write(..) how i can read/pull that file using the name 'abc.png' but not by multi-hash from other node 2

daviddias commented 5 years ago

You will have to do a ipfs.files.stat of the MFS root / and then grab that cid and call in the other node ipfs.files.cp the cid you got from the first node.

daviddias commented 5 years ago

https://github.com/ipfs-shipyard/cohosting packs a line of work and a set of conversations that should be interesting for you :)

thecipherBlock commented 5 years ago

@daviddias , can you give me insight on., how i can make it automate like

  1. doing _m = ipfs.files.stat('/') in node1
  2. going to node2 - using what (i mean without manual routing)
  3. doing ipfs.files.cp(_m) in node 2
daviddias commented 5 years ago

@its-VSP a few from multiple ways:

thecipherBlock commented 5 years ago

Thanks @daviddias ., we had made use of IPNS earlier but my only question is "how i can manage that static multihash[of IPNS] between the nodes" where that ipns has a single File which is having updated heads(root hashes) of every node within a cluster Do you have any idea or suggestion?

daviddias commented 5 years ago

@its-VSP I wasn't able to fully grasp what you are trying to build there. Wanna draw a picture and post an image here?

thecipherBlock commented 5 years ago

@daviddias Okay. Let's say there is a load balancer which balances request between node1 and node2 , My question was how node 1 and 2 can look to only one ipns consisting a file having a updated hash of MFS roots of both of the nodes

Without hard coding the ipns- hash within the source code

daviddias commented 5 years ago

@its-VSP the IPNS name is pegged to the private/public key pair. You should keep the multihash of it around, store it somewhere (DNSname, some db, hardcoded) so that it can be bootstrapped.

thecipherBlock commented 5 years ago

Thanks @daviddias .

daviddias commented 5 years ago

You bet :)

thecipherBlock commented 5 years ago

Yes i did @daviddias Had another issue but don't know this is the correct place or not to ask

ipfs.files.flush is returning nothing., and even the data is not being flushed

Hypothesis : I wanna flush the mfs root of node 1 before copying the updated mfs root from node 2

daviddias commented 5 years ago

@its-VSP that is a bug to report for go-ipfs https://github.com/ipfs/go-ipfs