예제 #1
0
        public async Task <IActionResult> Copy(
            [FromForm] CopyRequest copyRequest)
        {
            try
            {
                if (copyRequest.source == null)
                {
                    return(BadRequest("Copy source is not specified"));
                }

                if (copyRequest.target == null)
                {
                    return(BadRequest("Copy target is not specified"));
                }

                var result = await _fileSystemService
                             .CopyAsync(
                    new CopyState(
                        new NPath(copyRequest.target),
                        new NPath(copyRequest.source)));

                if (result == null)
                {
                    throw new SystemException("Unable to process copy");
                }

                return(Json(result));
            }
            catch (Exception e)
            {
                return(BadRequest(e));
            }
        }