Beispiel #1
0
 public IActionResult Upload(string sessionid, string language)
 {
     return(this.RequestHandler(language, () =>
     {
         string userId = _logic.GetUserId(language, sessionid);
         var file = Request.Form.Files[0];
         string message = _fileService.ValidFile(userId, file.FileName, file.Length, language);
         if (!string.IsNullOrEmpty(message))
         {
             throw new MessagesException(new List <string> {
                 message
             });
         }
         string filePath = _fileService.GetFilePath(userId, file.FileName);
         using (var stream = new FileStream(filePath, FileMode.Create))
         {
             file.CopyTo(stream);
         }
         return Ok(new MessageResponse {
             Message = "OK"
         });
     }));
 }