Starts in:
0 DAY
7 HRS
22 MIN
38 SEC
Starts in:
0 D
7 H
22 M
38 S
Open Closed

Azure Blob Name Calculator question #6180


User avatar
0
paykoolbackend created

Hello,

https://docs.abp.io/en/abp/latest/Blob-Storing-Azure#options

I would like to know if it's possible to remove the "host" string and directly use the blob name as the path under the container. (My current tenant is null)

Now: test1(container name)/host/data/test.pdf Expect: test2(container name)/data/test.pdf

Thanks.

  • ABP Framework version: v7.1.1
  • UI Type: Flutter
  • Database System: EF Core (SQL Server) / MongoDB
  • Tiered (for MVC) or Auth Server Separated (for Angular):
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

5 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You can override the DefaultAzureBlobNameCalculator service.

    https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.BlobStoring.Azure/Volo/Abp/BlobStoring/Azure/DefaultAzureBlobNameCalculator.cs#L18

  • User Avatar
    0
    paykoolbackend created

    hi

    I wrote the following code to override the DefaultAzureBlobNameCalculator service, but it cannot enter the TestBlobNameCalculator/Calculate.

    And throw error "Could not found the requested BLOB 'test.pdf' in the container 'TestContainer'!".

    Did I miss something?

    public class TestBlobNameCalculator : DefaultAzureBlobNameCalculator
    {
        public TestBlobNameCalculator(ICurrentTenant currentTenant) : base(currentTenant)
        {
        }
    
        public override string Calculate(BlobProviderArgs args)
        {
            if (args.ContainerName == "testContainer")
            {c
                return args.BlobName;
            }
    
            return base.Calculate(args);
        }
    }
    
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    And throw error "Could not found the requested BLOB 'test.pdf' in the container 'TestContainer'!".

    Please share the full error stack. Thanks.

  • User Avatar
    0
    paykoolbackend created

    I found a solution.

    https://docs.abp.io/en/abp/latest/Customizing-Application-Modules-Overriding-Services#overriding-a-service-class

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Great!

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06