1
0
mirror of https://github.com/sasjs/server.git synced 2026-01-12 08:40:04 +00:00

chore: comments addressing

This commit is contained in:
Mihajlo Medjedovic
2021-10-15 12:43:22 +00:00
parent 17a7a26fc3
commit c0a4e1aa14
12 changed files with 88 additions and 62 deletions

View File

@@ -60,7 +60,7 @@ ${program}`
}
}
let code = path.join(session.path, 'code.sas')
const code = path.join(session.path, 'code.sas')
if (!(await fileExists(code))) {
await createFile(code, program)
}
@@ -82,10 +82,6 @@ ${program}`
if (await fileExists(log)) log = await readFile(log)
else log = ''
// if (stderr) {
// return Promise.reject({ error: stderr, log: log })
// }
if (await fileExists(webout)) webout = await readFile(webout)
else webout = ''

View File

@@ -0,0 +1,36 @@
import { uuidv4 } from '@sasjs/utils'
import { getSessionController } from '.'
const multer = require('multer')
export class FileUploadController {
private storage = multer.diskStorage({
destination: function (req: any, file: any, cb: any) {
//Sending the intercepted files to the sessions subfolder
cb(null, req.sasSession.path)
},
filename: function (req: any, file: any, cb: any) {
//req_file prefix + unique hash added to sas request files
cb(null, `req_file_${uuidv4().replace(/-/gm, '')}`)
}
})
private upload = multer({ storage: this.storage })
//It will intercept request and generate uniqe uuid to be used as a subfolder name
//that will store the files uploaded
public preuploadMiddleware = async (req: any, res: any, next: any) => {
let session
const sessionController = getSessionController()
session = await sessionController.getSession()
session.inUse = true
req.sasSession = session
next()
}
public getMulterUploadObject() {
return this.upload
}
}

View File

@@ -70,7 +70,7 @@ export class SessionController {
this.scheduleSessionDestroy(session)
this.executionController.execute('', autoExec, session).catch((err) => {})
this.executionController.execute('', autoExec, session).catch(() => {})
this.sessions.push(session)

View File

@@ -1,3 +1,4 @@
export * from './deploy'
export * from './Session'
export * from './Execution'
export * from './FileUploadController'