psi-4ward / psitransfer

Simple open source self-hosted file sharing solution.
BSD 2-Clause "Simplified" License
1.48k stars 216 forks source link

Antivirus integration #187

Closed scrummie02 closed 2 years ago

scrummie02 commented 2 years ago

I have found this antivirus solution which accepts api requests: https://github.com/mindcollapse/MalwareMultiScan

It would be great to integrate into psi transfer as an option to have when people upload it scans and if it gets a 200 success code allows the transfer/upload otherwise kicks back the error from the scanner. Is this possible if so what needs to change on the back side to do this?

psi-4ward commented 2 years ago

Hmm you could make tus to respekt the response of the afterComplete cb.

const endReq = () => {
    //  It MUST include the Upload-Offset header containing the new offset.
    res.set('Upload-Offset', offset)
    // The Server MUST acknowledge successful PATCH requests
    // with the 204 No Content status.
    res.status(204)
    res.end()
}

if (upload && upload.uploadLength === offset) {
  if(await after(req, upload, uploadId) !== false) {
    endReq();
  }
} else {
  endReq();
}

And introduce async afterUploadComplete hooks.