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:
@@ -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 = ''
|
||||
|
||||
|
||||
36
src/controllers/FileUploadController.ts
Normal file
36
src/controllers/FileUploadController.ts
Normal 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
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from './deploy'
|
||||
export * from './Session'
|
||||
export * from './Execution'
|
||||
export * from './FileUploadController'
|
||||
Reference in New Issue
Block a user