Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
584 B
4
Indexable
Never

server.post('/upload', upload.array('files'), function(req, res) {
  const title = req.body.title;
  const files = req.files;

  //console.log(title);
  //console.log(files);
  var jsonReturn=[];

  //Send file into skynet
  for(var i=0;i<files.length;i++){
  console.log("i",i);

	(async () => {
	    const skylink = await client.uploadFile(files[i].path);
	    jsonReturn.push(skylink);
	    console.log(`Upload successful, skylink: ${skylink}`);
	})();
	
  }
  
  //for(;jsonReturn.length!=files.length;){wait(500)}
  res.sendStatus(200);
  res.json({ jsonReturn:jsonReturn});
});