Beispiel #1
0
        public new ResxVideoResult Upload(IFormFile file, bool useNewFileName = true)
        {
            ResxResult result = base.Upload(file, useNewFileName);

            if (!result.Success)
            {
                return(new ResxVideoResult(result.Success, result.Message));
            }

            if (!this.IsThumbnail)
            {
                return(new ResxVideoResult(result.Success, result.Message, result.ResxAccessUrl));
            }

            this.BuildThumbnailPath();
            var ret = this.CatchImage(base.SaveLocalPath, this.SaveThumbnailLocalPath);

            return(new ResxVideoResult()
            {
                Success = result.Success,
                Message = result.Message,
                ResxAccessUrl = result.ResxAccessUrl,
                ImagePreviewUrl = ret.Item1 ? string.Format("{0}/{1}", base.AccessUrl, this.ThumbnailImageName) : null,
                ImageWidth = ret.Item2,
                ImageHeight = ret.Item3,
                Duration = ret.Item4
            });
        }
Beispiel #2
0
        public ResxResult Upload(IFormFile file, bool useNewFileName = true)
        {
            ResxResult result     = new ResxResult();
            FileStream fileStream = null;

            try
            {
                this.CheckParams(file);

                string newFileName = useNewFileName ? GetNewFileName(file.FileName) : file.FileName;
                this.SaveLocalPath = Path.Combine(this.SaveLocalDirectory, newFileName);

                fileStream = File.Create(this.SaveLocalPath);
                file.CopyTo(fileStream);
                fileStream.Flush();

                result.ResxSize      = file.Length;
                result.Success       = true;
                result.ResxAccessUrl = string.Format("{0}/{1}", this.AccessUrl, newFileName);
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.Message = ex.Message;
                return(result);
            }
            finally
            {
                fileStream?.Close();
            }

            return(result);
        }
Beispiel #3
0
        public new ResxImageResult Upload(IFormFile file, bool useNewFileName = true)
        {
            ResxResult result = base.Upload(file, useNewFileName);

            if (!result.Success)
            {
                return(new ResxImageResult(result.Success, result.Message));
            }

            if (!this.IsThumbnail)
            {
                Size size = ImageSharpUtils.GetImageSize(base.SaveLocalPath);
                return(new ResxImageResult()
                {
                    Success = result.Success,
                    Message = result.Message,
                    ResxAccessUrl = result.ResxAccessUrl,
                    ImageWidth = size.Width,
                    ImageHeight = size.Height
                });
            }
            else
            {
                this.BuildThumbnailPath();
                Size size = ImageSharpUtils.ThumbnailImage(base.SaveLocalPath, this.SaveThumbnailLocalPath, this.ThumbnailImageWidth, this.ThumbnailImageHeight, this.ThumbnailQuality);
                return(new ResxImageResult()
                {
                    Success = result.Success,
                    Message = result.Message,
                    ResxAccessUrl = result.ResxAccessUrl,
                    ImagePreviewUrl = string.Format("{0}/{1}", base.AccessUrl, this.ThumbnailImageName),
                    ImageWidth = size.Width,
                    ImageHeight = size.Height
                });
            }
        }