Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="rootDirectory">The root directory (physical location)</param>
        /// <param name="url">URL of root directory</param>
        /// <param name="thumbnailsUrl">URL of where to find thumbnails</param>
        /// <param name="directorySeparatorChar">Character used to separate directory levels in a path string. Default is System.IO.Path.DirectorySeparatorChar</param>
        public RootVolume(
            string rootDirectory,
            string url,
            string thumbnailsUrl        = null,
            char directorySeparatorChar = default)
        {
            if (rootDirectory == null)
            {
                throw new ArgumentNullException("rootDirectory", "Root directory cannot be null");
            }

            Alias           = Path.GetFileNameWithoutExtension(rootDirectory);
            RootDirectory   = rootDirectory;
            Url             = url;
            UploadOverwrite = true;
            PictureEditor   = new DefaultPictureEditor();

            // https://github.com/EvgenNoskov/Elfinder.NET/blob/fb19f17a3682ed81cadcfea978dcce575806eebd/docs/Documentation.md
            if (!string.IsNullOrEmpty(thumbnailsUrl))
            {
                ThumbnailUrl = thumbnailsUrl;
            }

            DirectorySeparatorChar = directorySeparatorChar == default(char) ? Path.DirectorySeparatorChar : directorySeparatorChar; // Can be changed for other providers
            ThumbnailDirectory     = $"{rootDirectory}{DirectorySeparatorChar}.tmb";
        }
Example #2
0
        private async Task <ImageWithMimeType> GenerateThumbnailFromBlobItemToLocalFile(string filePath)
        {
            // We use ticks in the thumbnail filename request to be sure that the thumbnail will be re-created
            // if an image with the same filename will be uploaded again
            var lastIndexOf    = filePath.LastIndexOf('_');
            var ticks          = Path.GetFileNameWithoutExtension(filePath.Substring(lastIndexOf + 1, filePath.Length - lastIndexOf - 1));
            var originFilePath = filePath.Replace($"_{ticks}", "");

            await using var original = await AzureBlobStorageApi.FileStreamAsync($"{AzureBlobStorageApi.ContainerName}{originFilePath}");

            var image = new DefaultPictureEditor().GenerateThumbnail(original, _thumbnailSize, true);

            SaveFile(image.ImageStream, filePath);

            return(image);
        }
Example #3
0
        public RootVolume(string rootDirectory, string url, string thumbnailsUrl = null)
        {
            if (rootDirectory == null)
            {
                throw new ArgumentNullException("rootDirectory", "Root directory cannot be null");
            }

            Alias           = Path.GetFileNameWithoutExtension(rootDirectory);
            RootDirectory   = rootDirectory;
            Url             = url;
            UploadOverwrite = true;
            ThumbnailSize   = 48;
            PictureEditor   = new DefaultPictureEditor();

            // https://github.com/EvgenNoskov/Elfinder.NET/blob/fb19f17a3682ed81cadcfea978dcce575806eebd/docs/Documentation.md
            if (!string.IsNullOrEmpty(thumbnailsUrl))
            {
                ThumbnailUrl = thumbnailsUrl;
            }

            ThumbnailDirectory = string.Concat(rootDirectory, "/", ".tmb");
        }