aspnetboilerplate: Facing Problem when embedding file

  • Your Abp package version: 3.0.0.0
  • Your base framework: .Net Core.

EmbeddedResourceSet has bug if the embedded file has “-”

This is because of this segment of code:

private string ConvertToRelativePath(string resourceName) {
    resourceName = resourceName.Substring(ResourceNamespace.Length + 1);

    var pathParts = resourceName.Split('.');
    if (pathParts.Length <= 2)
    {
        return resourceName;
    }            
    var folder = pathParts.Take(pathParts.Length - 2).Select(NormalizeFolderName).JoinAsString("/");
    var fileName = pathParts[pathParts.Length - 2] + "." + pathParts[pathParts.Length - 1];

    return folder + "/" + fileName;
}

When pathParts.Length <= 2, the code did not normalize the string,

However, when retrieving fileinfo. EmbeddedResourceManager normalizes the string no matter when:

public EmbeddedResourceItem GetResource(string fullPath)
{
    return _resources.Value.GetOrDefault(EmbeddedResourcePathHelper.NormalizePath(fullPath));
}

To reproduce it: Embed a file with “-” located in the root level, then try to get file info of it using EmbeddedResourceFileProvider

Expected: Get file info successfully Actual: File Info not found

Furthermore, since:

public IDirectoryContents GetDirectoryContents(string subpath)
        {
            if (!IsInitialized())
            {
                return new NotFoundDirectoryContents();
            }

            //TODO: Implement...?

            return new NotFoundDirectoryContents();
        }

May I ask if there is a plan to implement this method?

Thank you.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 29 (14 by maintainers)

Most upvoted comments

That’s very good and seems solving all problems: https://github.com/aspnet/FileSystem/issues/184#issuecomment-352907578

We will try it when MS releases.

@acjh Great to know! Thanks! ^^ @robsiera If you are still facing issue, as a workaround, you can implement the IFileProvider yourself, see: https://github.com/chanjunweimy/abp_plugin_with_ui/blob/master/aspnet-core/src/Todo.MainProject.Web.Host/Services/PluginEmbeddedResourceFileProvider.cs

Good luck!

Cheers, Jun Wei

it is not yet released if I am not wrong

It was released in ABP v3.2.0. Current version is ABP v3.2.5.

@robsiera no problem. ^^ Actually @hikalkan has already solved the initial issue at this commit , but it is not yet released if I am not wrong. This is why this issue is marked as closed.

However, we continue the discussion in order to come out with a good method to implement GetDirectoryContents as specified in a new issue #2687 opened by @hikalkan . The pull request submitted by @sachatrauwaen is targeted for this issue I believe, that’s why I point out the potential issue of “not being able to download a complete folder” and suggest using “.zip” as a workaround.

Of course, none of these methods are perfect yet. Hopefully Microsoft implements something to solve this issue soon. ^^