Ejemplo n.º 1
0
        public virtual CachedImage Get(int?mediaFileId, MediaPathData data, ProcessImageQuery query = null)
        {
            Guard.NotNull(data, nameof(data));

            var resultExtension = query?.GetResultExtension();

            if (resultExtension != null)
            {
                data.Extension = resultExtension;
            }

            var imagePath = GetCachedImagePath(mediaFileId, data, query);
            var file      = _fileSystem.GetFile(BuildPath(imagePath));

            var result = new CachedImage(file)
            {
                Path      = imagePath,
                Extension = data.Extension,
                IsRemote  = _fileSystem.IsCloudStorage
            };

            return(result);
        }
Ejemplo n.º 2
0
        private bool PreparePut(CachedImage cachedImage, Stream stream)
        {
            Guard.NotNull(cachedImage, nameof(cachedImage));

            if (stream == null)
            {
                return(false);
            }

            if (cachedImage.Exists)
            {
                _fileSystem.DeleteFile(BuildPath(cachedImage.Path));
            }

            // create folder if needed
            string imageDir = System.IO.Path.GetDirectoryName(cachedImage.Path);

            if (imageDir.HasValue())
            {
                _fileSystem.CreateFolder(BuildPath(imageDir));
            }

            return(true);
        }
Ejemplo n.º 3
0
 protected abstract Task ProcessImageAsync(MediaHandlerContext context, CachedImage cachedImage, Stream inputStream);