private string CalcTargetFolderAndFilename(UploadedFileRequest uploadedFile) { var fullPath = Path.Combine(GetWebRootPath(), uploadedFile.ServerRelativeFileNameAndPath); CreateFolderIfNecessary(fullPath); return(fullPath); }
public IActionResult SaveUploadedFile(UploadedFileRequest request) { if (ModelState.IsValid) { SingleResponse <string> response = new SingleResponse <string>(); response.Result = _xbService.SaveUploadedFile(request.UploadedFile); response.ResultCode = ResultCodes.normal; return(ResponseExtensions.ToHttpResponse(response)); } else { return(ValidationError.GetValidationErrorResponse(ModelState)); } }
public void Post(UploadedFileRequest uploadedFile) { try { //rely on the caller to add a unique identifier to the filename, and to specify the location on the server var fullPath = CalcTargetFolderAndFilename(uploadedFile); var fs = System.IO.File.Create(fullPath); fs.Write(uploadedFile.FileContent, 0, uploadedFile.FileContent.Length); fs.Close(); } catch (Exception e) { Console.WriteLine(e); throw; } }
/// <summary> /// This service just uploads the file, it creates no DB objects /// </summary> public async Task UploadAsync(UploadedFileRequest uploadedFile) { try { MsgLogger.WriteTrace("FileUploadService Uploading file"); await ApiClient.PostAsJsonAsync <UploadedFileRequest>("/api/fileupload", uploadedFile); } catch (Exception e) { MsgLogger.WriteError($"FileUploadServie exception: {e.Message}"); throw; } finally { MsgLogger.WriteTrace("FileUploadService done Uploading file"); } }