Esempio n. 1
0
        public GetImageResultImage(int width, int height, GetImageResult inner)
            : base(width, height)
        {
            if (inner == null)
            {
                throw new ArgumentNullException(nameof(inner));
            }
            if (inner.Data.Count != width * height * 4)
            {
                throw new ArgumentException("The length of the data is not the expected value.");
            }

            this._inner = inner;
        }
Esempio n. 2
0
        public async Task <FileStreamResult> DownloadImageAsync(DownloadImageRequest request)
        {
            try
            {
                ImageLocationParam param = new ImageLocationParam()
                {
                    BucketName = request.BucketName,
                    ImageName  = request.ImageName
                };

                GetImageResult result = await _minioRepository.GetImageByteAsync(param);

                return(new FileStreamResult(new MemoryStream(result.ImageData.GetAllBytes()), "image/jpeg"));
            }
            catch (Exception exception)
            {
                //SentrySdk.CaptureException(exception);
                throw;
            }
        }
Esempio n. 3
0
        public async Task <GetImageResult> GetImageByteAsync(ImageLocationParam param)
        {
            try
            {
                GetImageResult result = new GetImageResult();

                await _minio.GetObjectAsync(param.BucketName, param.ImageName,
                                            (stream) =>
                {
                    result.ImageData = new MemoryStream(stream.GetAllBytes());
                });

                //await _minio.GetObjectAsync(param.BucketName, param.ImageName, "test.jpg");

                return(result);
            }
            catch (Exception exception)
            {
                //SentrySdk.CaptureException(exception);
                throw;
            }
        }
Esempio n. 4
0
        public async Task <GetImageBase64Response> GetImageBase64Async(GetImageRequest request)
        {
            try
            {
                ImageLocationParam param = new ImageLocationParam()
                {
                    BucketName = request.BucketName,
                    ImageName  = request.ImageName
                };

                GetImageResult result = await _minioRepository.GetImageByteAsync(param);

                return(new GetImageBase64Response()
                {
                    ImageBase64 = Convert.ToBase64String(result.ImageData.GetAllBytes())
                });
            }
            catch (Exception exception)
            {
                //SentrySdk.CaptureException(exception);
                throw;
            }
        }