-
Notifications
You must be signed in to change notification settings - Fork 11
How does Files API - ipfs files
command work.
#143
Comments
So here's me playing around with this feature. ~ $ ipfs files ls
~ $ ipfs files cp /ipfs/QmQwAP9vFjbCtKvD8RkJdCvPHqLQjZfW7Mqbbqx18zd8j7 /examples
~ $ ipfs files ls -l
examples QmQwAP9vFjbCtKvD8RkJdCvPHqLQjZfW7Mqbbqx18zd8j7 0
~ $ ipfs files ls -l /examples | column -t
Makefile QmVxEtpVTAjneTSC2vZukww5KfLMnHFsBA3XQZnMHNXXDf 157
api QmavsNYkgNcrNGgcmF6iq1SrkaaFNJVzqEnfVfdixFpPsk 0
basics QmYEcwYnCYb9CU6ipxRJvkFmBPwgRY4fD8eLLAj3rmetyi 0
bootstrap QmXRv4gRdokiarChpxF33jr35b6rexADEcdkwoFqKBRhzZ 0
config QmXhaJNHgzRaWqkdnmGJSPuxc12AueXeLda8F736MqPTbd 0
data QmTitSFQFQeBMZRDsGEvzdNgPnwx7coBCQxEYvNzgWPkK8 0
git Qmf6cuHtrDbqoKH2L8y9MtQUmGyNksR5RoKVNVvN23BG4G 0
graphmd QmfT4cEw9zezKaV6wF9aELFtpuovxFCR8CXSkUb6enAgw8 0
init QmTSE278Mb1dLXtco1wBbqaUCzD17hxRKGbqhZtUbNL3Vz 0
ipns QmUTWHFReYWNf6DX2GKy1kGXFecxQPaLTyZjVf2zKr28xu 0
network QmRPg57F8V46vvAGjdjARPtSMYj6wBicf482MJfen3M4LT 0
pinning QmXQNjQFBv8DxjgW1artxcXdhReFoaGRxhKqYgiMGPJ9o1 0
published-version QmPtqzMtd7ZLBWu9sF1xSUDfRZ6kkVnactBMKHdsMC1ZtJ 188
snapshots QmYuo1vhfDNTAmTPakchttvamQj6aLFjv6J5oeUJZhC99M 0
videos QmaJ8xTbRqTFBKEfePvL5tS3iAZJUMRWtUX9k8Pm9Sh8pT 0
websites QmZdWW55p6YTkFnGZHUmdVZjVKaBA745FENzftoYdapU9g 0
~ $ ipfs files cp /ipfs/QmQwAP9vFjbCtKvD8RkJdCvPHqLQjZfW7Mqbbqx18zd8j7 /test
~ $ ipfs files ls -l
examples QmQwAP9vFjbCtKvD8RkJdCvPHqLQjZfW7Mqbbqx18zd8j7 0
test QmQwAP9vFjbCtKvD8RkJdCvPHqLQjZfW7Mqbbqx18zd8j7 0
~ $ # gaaah, no columns....
~ $ ipfs files ls -l | column -t
examples QmQwAP9vFjbCtKvD8RkJdCvPHqLQjZfW7Mqbbqx18zd8j7 0
test QmQwAP9vFjbCtKvD8RkJdCvPHqLQjZfW7Mqbbqx18zd8j7 0
~ $ ipfs files rm -r /test
~ $ ipfs files mkdir /test
~ $ ipfs files cp /ipfs/QmQwAP9vFjbCtKvD8RkJdCvPHqLQjZfW7Mqbbqx18zd8j7 /test/otherExamples
~ $ ipfs files ls -l | column -t
examples QmQwAP9vFjbCtKvD8RkJdCvPHqLQjZfW7Mqbbqx18zd8j7 0
test QmdQ3wVuxPPSjbihiDKndwYBFQDtGWznEdmnjLEpdEphas 0
~ $ ipfs files ls -l /test | column -t
otherExamples QmQwAP9vFjbCtKvD8RkJdCvPHqLQjZfW7Mqbbqx18zd8j7 0
~ $ ipfs files stat /
QmTffJW1tzPwikLeCAFw7t4DbZidVGwVM1oMs96PTy25tk
Size: 0
CumulativeSize: 794139
ChildBlocks: 2
Type: directory
~ $ ipfs files cp ./pic/dukesOfNyan.gif /test/dukesOfNyan.gif
Error: Paths must start with a leading slash.
~ $ # I expected that to work...
~ $ ipfs add ./pic/dukesOfNyan.gif
added QmeFBEVocqUpuob62umabRuSXERGFwF6TVK3ZqBAdv3VjL dukesOfNyan.gif
~ $ ipfs files cp /ipfs/QmeFBEVocqUpuob62umabRuSXERGFwF6TVK3ZqBAdv3VjL /test/dukesOfNyan.gif
~ $ ipfs files ls -l /test | column -t
dukesOfNyan.gif QmeFBEVocqUpuob62umabRuSXERGFwF6TVK3ZqBAdv3VjL 19411092
otherExamples QmQwAP9vFjbCtKvD8RkJdCvPHqLQjZfW7Mqbbqx18zd8j7 0
~ $ ipfs files ls -l / | column -t
examples QmQwAP9vFjbCtKvD8RkJdCvPHqLQjZfW7Mqbbqx18zd8j7 0
test QmX8NbuNEEqqxDNU1GuXyQST83EpqRt3gQweZeAGzpJFGc 0 So a few questions. Is this meant as a convenient editor for adding IPFS directory objects? Does this have an advantage over just editing a directory in the local file system and adding that? I see root has a hash as well. If someone requests that hash, will I give it to them? When I changed ~ $ ipfs object get /ipfs/QmdQ3wVuxPPSjbihiDKndwYBFQDtGWznEdmnjLEpdEphas
{"Links":[{"Name":"otherExamples","Hash":"QmQwAP9vFjbCtKvD8RkJdCvPHqLQjZfW7Mqbbqx18zd8j7","Size":396987}],"Data":"\u0008\u0001"}
~ $ ipfs object get /ipfs/QmX8NbuNEEqqxDNU1GuXyQST83EpqRt3gQweZeAGzpJFGc
{"Links":[{"Name":"dukesOfNyan.gif","Hash":"QmeFBEVocqUpuob62umabRuSXERGFwF6TVK3ZqBAdv3VjL","Size":19415747},{"Name":"otherExamples","Hash":"QmQwAP9vFjbCtKvD8RkJdCvPHqLQjZfW7Mqbbqx18zd8j7","Size":396987}],"Data":"\u0008\u0001"} So each modification done in I notice that entries into the files API are not pinned, should they be? Finally I'm trying to get an overall sense of what this command is intended for long term. This kinda seems like a porcelain command, more than a plumbing. Long term, are we all going to have an IPFS 'drive', that our file browsers understand, where we organize the contents of IPFS? |
Yes, among other things
depends on what your usecase is,
Each modification is stored unless you use the
This one is tricky, and something we havent quite finished. Stuff in the files API are not currently pinned, and they should not be pinned recursively. The reason for this is because one use case we want to explicitly support is
Thats one idea :) And one i very much support |
This issue has been moved to https://discuss.ipfs.io/t/how-does-files-api-ipfs-files-command-work/344. |
Just for future reference:
If I understood that correctly, you can safely remove the pin on a file you added after you've copied it with ipfs files. |
IPFS Files API allows to manipulate unixfs objects (current IPFS files and directories format) in manner similar to normal Unix commands.
How does it work:
IPFS Files API introduces virtual root directory. You can check it content with
ipfs files ls /
.You can copy files and directories that were added to IFPS using
ipfs files cp /ipfs/Qmc4xcnns2rA4akaWfGdzdaN8My1ES6zh7yddYZ5mo7n2U /greetings
.Then you can view content of that directory using
ipfs files ls /greetings
and read file in it usingipfs files read /greetings/greetings.md
.You can then modify the structure with different commands:
ipfs files mv /greetings/greetings.md /greetings/greetings.txt
, note that will change hash of the/greetings
directory. You can check new hash usingipfs files stat --hash /greetings
.If you have any more questions, please ask.
The text was updated successfully, but these errors were encountered: