예제 #1
0
        public IActionResult Upload(IFormFile file, int fileCategory)
        {
            var fileHeader = new FileHeader
            {
                FileExt     = file.FileName.Substring(file.FileName.LastIndexOf('.')),
                ContentType = file.ContentType,
                Length      = file.Length,
                Category    = fileCategory
            };

            var stream  = file.OpenReadStream();
            var content = new byte[stream.Length];

            stream.Read(content, 0, (int)stream.Length);

            _logic.SaveFile(fileHeader, content, out var result);
            return(Json(result));
        }
예제 #2
0
        public IActionResult Upload(IFormFile file, int fileCategory)
        {
            var fileHeader = new FileHeader
            {
                FileExt     = file.FileName.Substring(file.FileName.LastIndexOf('.')),
                ContentType = file.ContentType,
                Length      = file.Length,
                Category    = fileCategory
            };

            if (fileHeader.Length > 2 * 1024 * 1024)
            {
                return(Json(new ExcutedResult(EnumStatus.Error, "", BusinessResultCode.FileSizeThan2M, null)));
            }
            var stream  = file.OpenReadStream();
            var content = new byte[stream.Length];

            stream.Read(content, 0, (int)stream.Length);

            _logic.SaveFile(fileHeader, content, out var result);
            return(Json(result));
        }