@@ -25,7 +25,7 @@ interface-ipfs-core API.
25
25
26
26
![ ] ( /img/badge.png )
27
27
28
- # How to use the battery tests
28
+ # How to use the battery of tests
29
29
30
30
## Node.js
31
31
@@ -55,6 +55,86 @@ test.all(common)
55
55
56
56
A valid (read: that follows this interface) IPFS core implementation, must expose the following API.
57
57
58
+ ## Files
59
+
60
+ ### ` add `
61
+
62
+ > Add files and data to IPFS.
63
+
64
+ ##### ` Go ` ** WIP**
65
+
66
+ ##### ` JavaScript ` - ipfs.files.add(data, [ callback] )
67
+
68
+ Where ` data ` may be
69
+
70
+ - an array of objects, each of the form
71
+ ``` js
72
+ {
73
+ path: ' /tmp/myfile.txt' ,
74
+ content: (Buffer or Readable stream)
75
+ }
76
+ ```
77
+ - a ` Buffer ` instance
78
+ - a ` Readable ` stream
79
+
80
+ ` callback ` must follow ` function (err, res) {} ` signature, where ` err ` is an
81
+ error if the operation was not successful. ` res ` will be an array of
82
+ [ DAGNode] [ ] s.
83
+
84
+ If no ` callback ` is passed, a promise is returned.
85
+
86
+ ``` js
87
+ var files = [
88
+ {
89
+ path: ' /tmp/myfile.txt' ,
90
+ content: fs .createReadStream (' /tmp/myfile.txt' )
91
+ }
92
+ ]
93
+ ipfs .files .add (files, function (err , dagNodes ) {
94
+ // 'res' will be an array of DAGNodes
95
+ })
96
+ ```
97
+
98
+
99
+ ### ` createAddStream `
100
+
101
+ > Add files and data to IPFS using a transform stream.
102
+
103
+ ##### ` Go ` ** WIP**
104
+
105
+ ##### ` JavaScript ` - ipfs.files.createAddStream([ callback] )
106
+
107
+ Provides a Transform stream, where objects can be written of the forms
108
+
109
+ ``` js
110
+ {
111
+ path: ' /tmp/myfile.txt' ,
112
+ content: (Buffer or Readable stream)
113
+ }
114
+ ```
115
+
116
+ ` callback ` must follow ` function (err, stream) {} ` signature, where ` err ` is an
117
+ error if the operation was not successful. ` stream ` will be a Transform stream,
118
+ to which tuples like the above two object formats can be written and [ DAGNode] [ ]
119
+ objects will be outputted.
120
+
121
+ If no ` callback ` is passed, a promise is returned.
122
+
123
+ ``` js
124
+ ipfs .files .createAddStream (function (err , stream ) {
125
+ stream .on (' data' , function (dagNode ) {
126
+ // ...
127
+ })
128
+
129
+ stream .write ({path: < path to file> , content: < buffer or readable stream> })
130
+ // write as many as you want
131
+
132
+ stream .end ()
133
+ })
134
+ ```
135
+
136
+
137
+
58
138
## Object
59
139
60
140
### ` object.new `
0 commit comments