Exemple #1
0
        public async Task <FullPath> ParsePathAsync(string target)
        {
            if (string.IsNullOrEmpty(target))
            {
                return(null);
            }

            string volumePrefix = null;
            string pathHash     = null;

            for (int i = 0; i < target.Length; i++)
            {
                if (target[i] == '_')
                {
                    pathHash     = target.Substring(i + 1);
                    volumePrefix = target.Substring(0, i + 1);
                    break;
                }
            }

            var    root   = Roots.First(r => r.VolumeId == volumePrefix);
            string path   = HttpEncoder.DecodePath(pathHash);
            string dirUrl = path != root.RootDirectory ? path : string.Empty;
            var    dir    = new AzureStorageDirectory(root.RootDirectory + dirUrl);

            if (await dir.ExistsAsync)
            {
                return(new FullPath(root, dir, target));
            }
            else
            {
                var file = new AzureStorageFile(root.RootDirectory + dirUrl);
                return(new FullPath(root, file, target));
            }
        }
Exemple #2
0
        public async Task <FullPath> ParsePathAsync(string target)
        {
            if (string.IsNullOrEmpty(target))
            {
                return(null);
            }

            int    underscoreIndex = target.IndexOf('_');
            string pathHash        = target.Substring(underscoreIndex + 1);
            string volumePrefix    = target.Substring(0, underscoreIndex + 1);

            var    root          = Roots.First(r => r.VolumeId == volumePrefix);
            var    rootDirectory = new DirectoryInfo(root.RootDirectory);
            string path          = HttpEncoder.DecodePath(pathHash);
            string dirUrl        = path != rootDirectory.Name ? path : string.Empty;
            var    dir           = new FileSystemDirectory(root.RootDirectory + dirUrl);

            if (await dir.ExistsAsync)
            {
                return(new FullPath(root, dir, target));
            }
            else
            {
                var file = new FileSystemFile(root.RootDirectory + dirUrl);
                return(new FullPath(root, file, target));
            }
        }
Exemple #3
0
        public async Task <IActionResult> Thumbs(string hash)
        {
            var filePath = HttpEncoder.DecodePath(hash);

            if (System.IO.File.Exists($"{_thumbnailsDir}{filePath}"))
            {
                return(StreamImageFromLocalFile(OpenFile(filePath)));
            }

            var image = await GenerateThumbnailFromBlobItemToLocalFile(filePath);

            return(StreamImageFromLocalFile(image));
        }
Exemple #4
0
        public async Task <FullPath> ParsePathAsync(string target)
        {
            if (string.IsNullOrEmpty(target))
            {
                return(null);
            }

            var split = StringHelpers.Split('_', target);

            var root   = Roots.First(r => r.VolumeId == split.Prefix);
            var path   = HttpEncoder.DecodePath(split.Content);
            var dirUrl = path != root.RootDirectory ? path : string.Empty;
            var dir    = new AzureBlobDirectory(root.RootDirectory + dirUrl);

            if (await dir.ExistsAsync)
            {
                return(new FullPath(root, dir, target));
            }

            var file = new AzureBlobFile(root.RootDirectory + dirUrl);

            return(new FullPath(root, file, target));
        }