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); }
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); }
protected abstract Task ProcessImageAsync(MediaHandlerContext context, CachedImage cachedImage, Stream inputStream);