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
feat: add support for File DOM API to files-regular (ipfs#986)
* feat: add file dom api support to files api
* feat: add support for File DOM API to files-regular
* chore: fix package declaration cause npm is dumb
* chore: fix lint
* chore: add ipfs-utils
* fix: change the requires to ipfs-utils
* chore: increase max bundle size
@@ -73,10 +80,36 @@ function loadPaths (opts, file) {
73
80
}
74
81
}
75
82
83
+
functioncontentToStream(content){
84
+
if(supportsFileReader&&kindOf(content)==='file'){
85
+
returnstreamFromFileReader(content)
86
+
}
87
+
88
+
if(kindOf(content)==='buffer'){
89
+
returnnewReadable({
90
+
read(){
91
+
this.push(content)
92
+
this.push(null)
93
+
}
94
+
})
95
+
}
96
+
97
+
if(isSource(content)){
98
+
returnpullToStream.readable(content)
99
+
}
100
+
101
+
if(isStream.readable(content)){
102
+
returncontent
103
+
}
104
+
105
+
thrownewError(`Input not supported. Expected Buffer|ReadableStream|PullStream|File got ${kindOf(content)}. Check the documentation for more info https://github.com/ipfs/interface-js-ipfs-core/blob/master/SPEC/FILES.md#add`)
106
+
}
107
+
76
108
functionprepareFile(file,opts){
77
109
letfiles=[].concat(file)
78
110
79
111
returnflatmap(files,(file)=>{
112
+
// add from fs with file path
80
113
if(typeoffile==='string'){
81
114
if(!isNode){
82
115
thrownewError('Can only add file paths in node')
@@ -85,20 +118,34 @@ function prepareFile (file, opts) {
0 commit comments