Coder Social home page Coder Social logo

elfinder.netcore.azurestorage's People

Contributors

danielmpetrov avatar emisand avatar fsmirne avatar golaat avatar gordon-matt avatar nhuthan avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

jizzaki hungngo96

elfinder.netcore.azurestorage's Issues

Support for archiving by directory using AzureStorageDriver

The BaseDriver only supports archiving local folders and files.

Please add an override to the AzureStorageDriver with the following:


 protected override async Task AddDirectoryToArchiveAsync(ZipArchive zipFile, IDirectory directoryInfo, string root)
        {
            string entryName = $"{root}{directoryInfo.Name}/";

            zipFile.CreateEntry(entryName);
            var dirs = await directoryInfo.GetDirectoriesAsync();

            foreach (var dir in dirs)
            {
                await AddDirectoryToArchiveAsync(zipFile, dir, entryName);
            }

            var files = await directoryInfo.GetFilesAsync(null);

            foreach (var file in files)
            {
                var filePath = Path.GetTempFileName();
                File.WriteAllBytes(filePath, await AzureStorageAPI.FileBytesAsync(file.FullName));
                zipFile.CreateEntryFromFile(filePath, entryName + file.Name);
            }
        }

This will allow us to retrieve files from Azure Instead and write to a temp directory. This currently does not exist in the AzureStorageDriver and fails every time you try to archive by directory/folder name.

Error renaming or moving a folder that contains files

Bug in file AzureStorageAPI.cs line 356.

When renaming or moving a directory this method will fail if that directory contains files. Microsoft's directory DeleteAsync() method will not delete a directory that contains files. I'm new to Github my apologies for not submitting a pull request.

Issue:

  public static async Task MoveDirectoryAsync(string source, string destination)
        {
            await CopyDirectoryAsync(source, destination);

            var rootDir = GetRootDirectoryReference(source);
            var sourceDir = rootDir.GetDirectoryReference(RelativePath(source));

            await sourceDir.DeleteAsync();
        }

Recommended solution:

  public static async Task MoveDirectoryAsync(string source, string destination)
        {
            await CopyDirectoryAsync(source, destination);

            // In order to delete a directory it must first be empty per Microsoft
            // https://docs.microsoft.com/en-us/rest/api/storageservices/delete-directory
            // Instead, we should recursively delete the subfolders, files, and lastly the source folder.
            await DeleteDirectoryAsync(source);
        }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.