You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 10, 2020. It is now read-only.
@@ -590,28 +590,49 @@ A great source of [examples][] can be found in the tests for this API.
590
590
591
591
The Mutable File System (MFS) is a virtual file system on top of IPFS that exposes a Unix like API over a virtual directory. It enables users to write and read from paths without having to worry about updating the graph. It enables things like [ipfs-blob-store](https://github.com/ipfs/ipfs-blob-store) to exist.
##### `JavaScript` - ipfs.files.cp(...from, to, [options], [callback])
601
600
602
601
Where:
603
602
604
-
-`from` is the path of the source file to copy.
605
-
-`to` is the path of the destination file to copy to.
603
+
-`from` is the path(s) of the source to copy. It might be:
604
+
- An existing MFS path (e.g. `/my-dir/my-file.txt`)
605
+
- An IPFS path (e.g. `/ipfs/QmWGeRAEgtsHW3ec7U4qW2CyVy7eA2mFRVbk1nb24jFyks`)
606
+
-`to` is the path of the destination to copy to
607
+
-`options` is an optional Object that might contain the following keys:
608
+
-`parents` is a Boolean value to decide whether or not to make the parent directories if they don't exist (default: false)
609
+
-`format` is what type of nodes to write any newly created directories as (default: `dag-pb`)
610
+
-`hashAlg` is which algorithm to use when creating CIDs for newly created directories (default: `sha2-256`)
611
+
-`flush` is a Boolean value to decide whether or not to immediately flush MFS changes to disk (default: true)
612
+
-`callback` is an optional function with the signature `function (error) {}`, where `error` may be an Error that occured if the operation was not successful
613
+
614
+
If there are multiple sources, `to` will be treated as a directory, otherwise it will be treated as the same type as `from`.
606
615
607
-
`callback` must follow the `function (err) {}` signature, where `err` is an Error if the operation was not successful.
616
+
If `from` is an IPFS path, and an MFS path exists with the same name, the IPFS path will be chosen.
608
617
609
618
If no `callback` is passed, a promise is returned.
-`options` is an optional Object that might contain the following keys:
633
-
-`parents` is a Boolean value to decide whether or not to make the parent directories if they don't exist.
634
-
635
-
`callback` must follow the `function (err) {}` signature, where `err` is an Error if the operation was not successful.
654
+
-`parents` is a Boolean value to decide whether or not to make the parent directories if they don't exist (default: false)
655
+
-`format` is what type of nodes to write any newly created directories as (default: `dag-pb`)
656
+
-`hashAlg` is which algorithm to use when creating CIDs for newly created directories (default: `sha2-256`)
657
+
-`flush` is a Boolean value to decide whether or not to immediately flush MFS changes to disk (default: true)
658
+
-`callback` is an optional function with the signature `function (error) {}`, where `error` may be an Error that occured if the operation was not successful
636
659
637
660
If no `callback` is passed, a promise is returned.
-`path` is the path to the file or directory to stat
660
683
-`options` is an optional Object that might contain the following keys:
661
-
-`hash` is a Boolean value to return only the hash.
662
-
-`size` is a Boolean value to return only the size.
663
-
-`withLocal` is a Boolean value to compute the amount of the dag that is local, and if possible the total size.
664
-
665
-
`callback` must follow the `function (err, stat) {}` signature, where `err` is an Error if the operation was not successful and `stat` is an Object with the following keys:
666
-
667
-
-`hash` is a string with the hash.
668
-
-`size` is an integer with the size in Bytes.
669
-
-`cumulativeSize` is an integer with the cumulative size in Bytes.
670
-
-`blocks` is an integer indicating the number of blocks.
671
-
-`type` is a string that can be either `directory` or `file`.
672
-
-`withLocality` is a boolean to indicate if locality information are present.
673
-
-`local` is a boolean to indicate if the queried dag is fully present locally.
674
-
-`sizeLocal` is an integer indicating the cumulative size of the data present locally.
675
-
684
+
-`hash` is a Boolean value to return only the hash (default: false)
685
+
-`size` is a Boolean value to return only the size (default: false)
686
+
-`withLocal` is a Boolean value to compute the amount of the dag that is local, and if possible the total size (default: false)
687
+
-`callback` is an optional function with the signature `function (error, stats) {}`, where `error` may be an Error that occured if the operation was not successful and `stat` is an Object with the following keys:
688
+
689
+
-`hash` is a string with the hash
690
+
-`size` is an integer with the file size in Bytes
691
+
-`cumulativeSize` is an integer with the size of the DAGNodes making up the file in Bytes
692
+
-`type` is a string that can be either `directory` or `file`
693
+
-`blocks` if `type` is `directory`, this is the number of files in the directory. If it is `file` it is the number of blocks that make up the file
694
+
-`withLocality` is a boolean to indicate if locality information are present
695
+
-`local` is a boolean to indicate if the queried dag is fully present locally
696
+
-`sizeLocal` is an integer indicating the cumulative size of the data present locally
676
697
677
698
If no `callback` is passed, a promise is returned.
-`options` is an optional Object that might contain the following keys:
707
-
-`recursive` is a Boolean value to decide whether or not to remove directories recursively.
708
-
709
-
`callback` must follow the `function (err) {}` signature, where `err` is an Error if the operation was not successful.
728
+
-`recursive` is a Boolean value to decide whether or not to remove directories recursively (default: false)
729
+
-`callback` is an optional function with the signature `function (error) {}`, where `error` may be an Error that occured if the operation was not successful
710
730
711
731
If no `callback` is passed, a promise is returned.
-`path` is the path of the file to read and must point to a file
742
769
-`options` is an optional Object that might contain the following keys:
743
-
-`offset` is an Integer with the byte offset to begin reading from.
744
-
-`count` is an Integer with the maximum number of bytes to read.
745
-
746
-
`callback` must follow the `function (err, buf) {}` signature, where `err` is an Error if the operation was not successful and `buf` is a [`Buffer`][b] with the contents of `path`.
770
+
-`offset` is an Integer with the byte offset to begin reading from (default: 0)
771
+
-`length` is an Integer with the maximum number of bytes to read (default: Read to end of stream)
772
+
-`callback` is an optional function with the signature `function (error, buffer) {}`, where `error` may be an Error that occured if the operation was not successful and `buffer` is a [`Buffer`][b] with the contents of `path`
747
773
748
774
If no `callback` is passed, a promise is returned.
749
775
776
+
N.b. this method is likely to result in high memory usage, you should use [files.readReadableStream](#filesreadreadablestream) or [files.readPullStream](#filesreadpullstream) instead where possible.
- a [`Blob`][blob] (caveat: will only work in the browser)
831
859
- a string path to a file (caveat: will only work in Node.js)
832
860
-`options` is an optional Object that might contain the following keys:
833
-
-`offset` is an Integer with the byte offset to begin writing at.
834
-
-`create` is a Boolean to indicate to create the file if it doesn't exist.
835
-
-`truncate` is a Boolean to indicate if the file should be truncated to size 0 before writing.
836
-
-`count` is an Integer with the maximum number of bytes to read.
837
-
838
-
`callback` must follow the `function (err) {}` signature, where `err` is an Error if the operation was not successful.
861
+
-`offset` is an Integer with the byte offset to begin writing at (default: 0)
862
+
-`create` is a Boolean to indicate to create the file if it doesn't exist (default: false)
863
+
-`truncate` is a Boolean to indicate if the file should be truncated after writing all the bytes from `content` (default: false)
864
+
-`length` is an Integer with the maximum number of bytes to read (default: Read all bytes from `content`)
865
+
-`callback` is an optional function with the signature `function (error) {}`, where `error` may be an Error that occured if the operation was not successful
839
866
840
867
If no `callback` is passed, a promise is returned.
##### `JavaScript` - ipfs.files.mv(...from, to, [options], [callback])
857
884
858
885
Where:
859
886
860
-
-`from` is the path of the source file to move.
861
-
-`to` is the path of the destination file to move to.
887
+
-`from` is the path(s) of the source to move
888
+
-`to` is the path of the destination to move to
889
+
-`options` is an optional Object that might contain the following keys:
890
+
-`parents` is a Boolean value to decide whether or not to make the parent directories if they don't exist (default: false)
891
+
-`format` is what type of nodes to write any newly created directories as (default: `dag-pb`)
892
+
-`hashAlg` is which algorithm to use when creating CIDs for newly created directories (default: `sha2-256`)
893
+
-`flush` is a Boolean value to decide whether or not to immediately flush MFS changes to disk (default: true)
894
+
-`callback` is an optional function with the signature `function (error) {}`, where `error` may be an Error that occured if the operation was not successful
862
895
863
-
`callback` must follow the `function (err) {}` signature, where `err` is an Error if the operation was not successful.
896
+
If there are multiple sources, `to` will be treated as a directory, otherwise it will be treated as the same type as `from`.
864
897
865
898
If no `callback` is passed, a promise is returned.
`callback` must follow the `function (err) {}` signature, where `err` is an Error if the operation was not successful.
932
+
-`paths` are an optional string paths to flush (default: `/`)
933
+
-`callback` is an optional function with the signature `function (error) {}`, where `error` may be an Error that occured if the operation was not successful
890
934
891
935
If no `callback` is passed, a promise is returned.
-`path` is the path to show listing for. Defaults to `/`.
914
-
-`options` is an optional Object that might contain the following keys:
915
-
-`l` is a Boolean value o use long listing format.
916
-
917
-
`callback` must follow `function (err, files) {}` signature, where `err` is an error if the operation was not successful. `files` is an array containing Objects that contain the following keys:
957
+
-`path` is an optional string to show listing for (default: `/`)
958
+
-`callback` is an optional function with the signature `function (error, files) {}`, where `error` may be an Error that occured if the operation was not successful and `files` is an array containing Objects that contain the following keys:
918
959
919
-
-`name` which is the file's name.
920
-
-`type` which i the object's type (`directory` or `file`).
921
-
-`size` the size of the file in bytes.
922
-
-`hash` the hash of the file.
960
+
-`name` which is the file's name
961
+
-`type` which i the object's type (`directory` or `file`)
962
+
-`size` the size of the file in bytes
963
+
-`hash` the hash of the file
923
964
924
965
If no `callback` is passed, a promise is returned.
0 commit comments