2016-03-10 12:17:26 -05:00
|
|
|
AuthorizationMiddlewear = require('../Authorization/AuthorizationMiddlewear')
|
2014-02-12 05:23:40 -05:00
|
|
|
AuthenticationController = require('../Authentication/AuthenticationController')
|
|
|
|
ProjectUploadController = require "./ProjectUploadController"
|
2015-12-01 08:08:49 -05:00
|
|
|
RateLimiterMiddlewear = require('../Security/RateLimiterMiddlewear')
|
2018-12-13 07:54:49 -05:00
|
|
|
Settings = require('settings-sharelatex')
|
|
|
|
multer = require('multer')
|
|
|
|
|
|
|
|
upload = multer(
|
|
|
|
dest: Settings.path.uploadFolder
|
|
|
|
limits: fileSize: Settings.maxUploadSize
|
|
|
|
)
|
2014-02-12 05:23:40 -05:00
|
|
|
|
|
|
|
module.exports =
|
2015-06-30 09:38:32 -04:00
|
|
|
apply: (webRouter, apiRouter) ->
|
|
|
|
webRouter.post '/project/new/upload',
|
2014-02-12 05:23:40 -05:00
|
|
|
AuthenticationController.requireLogin(),
|
2019-01-22 06:23:15 -05:00
|
|
|
RateLimiterMiddlewear.rateLimit({
|
|
|
|
endpointName: "project-upload"
|
|
|
|
maxRequests: 20
|
|
|
|
timeInterval: 60
|
|
|
|
}),
|
2018-12-13 07:54:49 -05:00
|
|
|
upload.single('qqfile'),
|
2014-02-12 05:23:40 -05:00
|
|
|
ProjectUploadController.uploadProject
|
2015-12-01 08:08:49 -05:00
|
|
|
|
2015-06-30 09:38:32 -04:00
|
|
|
webRouter.post '/Project/:Project_id/upload',
|
2015-12-01 08:08:49 -05:00
|
|
|
RateLimiterMiddlewear.rateLimit({
|
|
|
|
endpointName: "file-upload"
|
|
|
|
params: ["Project_id"]
|
2015-12-07 11:50:09 -05:00
|
|
|
maxRequests: 200
|
|
|
|
timeInterval: 60 * 30
|
2015-12-01 08:08:49 -05:00
|
|
|
}),
|
2016-03-21 09:23:14 -04:00
|
|
|
AuthenticationController.requireLogin(),
|
2016-03-10 12:17:26 -05:00
|
|
|
AuthorizationMiddlewear.ensureUserCanWriteProjectContent,
|
2018-12-13 07:54:49 -05:00
|
|
|
upload.single('qqfile'),
|
2014-02-12 05:23:40 -05:00
|
|
|
ProjectUploadController.uploadFile
|