MCPcopy Index your code
hub / github.com/wendux/fly / download

Function download

src/node/index.js:16–33  ·  view source on GitHub ↗
(url, savePath, params = null,options)

Source from the content-addressed store, hash-verified

14
15 // File download API
16 download(url, savePath, params = null,options) {
17 return this.request(url, params,utils.merge({responseType: "stream"},options))
18 .then(d => {
19 return new Promise((resolve,reject)=> {
20 fs.writeFile(savePath, d.data,(err)=>{
21 if(!err) {
22 resolve({size:d.data.length,path:path.resolve(savePath)})
23 }else{
24 // Failed to save file
25 err.status=2
26 reject(err)
27 }
28 })
29 })
30 }).catch(e=>{
31 return Promise.reject(e)
32 })
33 },
34
35 // File upload API
36 upload(url,formData,options) {

Callers

nothing calls this directly

Calls 1

requestMethod · 0.65

Tested by

no test coverage detected