Exemple #1
0
        public ActionResult <ExecutionResult> Get(string fileName, string jobId)
        {
            try {
                var stopwatch   = Stopwatch.StartNew();
                var directory   = Program.GetDirectory(jobId);
                var content     = System.IO.File.ReadAllBytes($"{directory}/{fileName}");
                var montageFile = new MontageFile(fileName, content);
                var response    = new ExecutionResult("OK", montageFile, stopwatch.ElapsedMilliseconds.ToString());

                return(response);
            } catch (Exception ex) {
                _logger.LogError(ex, "Error during fetching file");
                return(StatusCode(500));
            }
        }
Exemple #2
0
        public ActionResult <ExecutionResult> Post([FromBody] MontageFile file, string jobId)
        {
            try {
                var stopwatch = Stopwatch.StartNew();
                var directory = Program.GetDirectory(jobId);
                Directory.CreateDirectory(directory);

                using (var fileHandle = System.IO.File.Create($"{directory}/{file.Name}")) {
                    fileHandle.Write(file.Content);
                }

                var elapsedTime = stopwatch.ElapsedMilliseconds.ToString();

                _logger.LogInformation($"copied file in {elapsedTime}ms");

                return(Created($"api/file/{jobId}", new ExecutionResult("OK", "File successfully copied to server", elapsedTime)));
            } catch (Exception ex) {
                _logger.LogError(ex, "Error during creating file");
                return(StatusCode(500));
            }
        }