🐛 Fix corrupt zip and remove project download on server

This commit is contained in:
brunosimon
2017-12-25 17:49:53 +01:00
parent 3d93205750
commit 2620b00ffe
23 changed files with 148 additions and 60 deletions
+10 -7
View File
@@ -109,13 +109,16 @@ class Site
// Get zip buffer
const zipBuffer = _project.getZipBuffer()
// Send
response.writeHead(200, {
'Content-Type': 'application/zip',
'Content-Length': zipBuffer.length
})
response.write(zipBuffer, 'binary')
response.end(null, 'binary')
// Set finename
const date = new Date()
const hours = `${date.getHours() < 10 ? '0' : ''}${date.getHours()}`
const minutes = `${date.getMinutes() < 10 ? '0' : ''}${date.getMinutes()}`
const seconds = `${date.getSeconds() < 10 ? '0' : ''}${date.getSeconds()}`
const name = `${_project.slug}_${hours}-${minutes}-${seconds}.zip`
response.setHeader('Content-disposition', `attachment; filename=${name}`)
zipBuffer.pipe(response)
})
this.express.use('/' + _project.slug + '/files', express.static(_project.path))