New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Media.PublicUrl is wrong when using BlobStorage #1815
Comments
Hi! Could you please provide an example of how the correct URL you are expecting should be formatted. Regards |
Well, as you can see, the URL is in basically wrong, it uses the absolute URI which contains the query string of the container The (at least) 9.1.0 version of this library did it correct, it creates a URL that is |
I checked the code now; the problem is in the It uses the This is wrong in many ways (e.g. manipulating URLs should be done with UriBuilder), but a more correct way to retrieve the correct URL is to get the
This ensures that the correct blob URI is returned. However, the URI contains an SAS key which isn't good. To avoid this, a shadow container that uses the
It seems that the issue only occurs if you're using a SAS key to connect, if you use managed identity or the Shared Access Key for the storage it works. Steps to reproduce:
EDIT: I modified this post a bit, since I found this article at Microsoft that used the URL without the SAS key to retrieve the anonymous URL (The Microsoft example itself contains an error, but that's out of scope here, my example above works but is a bit ineffective). |
Hi, is the any update on this bug or a workaround? |
This will be released in the next minor version but we haven't started it yet. If you have the same issues as @dozer75 you can take his solution from previous comment and temporarily create your own BlobStorage implementation which you use instead of our package. Regards |
When using BlobStorage for media the URL that is generated in the PublicUrl is wrong. This worked in 9.1.0 (at least).
It uses a sas url and appends the filename like this:
https://<mystorage>.blob.core.windows.net/piranha-media?sv=2020-08-04&ss=b&srt=co&spr=https&st=2021-08-10T14%3A26%3A50Z&se=2025-12-30T23%3A26%3A50Z&sp=<sp>&sig=<sig>/c76c08bc-f5ba-43a4-af08-4c5bfdddc9e6/_MG_2955_210x160.jpg
The blob storage configuration is configured like this:
services.AddPiranhaBlobStorage(configuration.GetConnectionString("PiranhaBlobStorage"), "piranha-media", Piranha.Azure.BlobStorageNaming.UniqueFolderNames);
I can see in the code that in BlobStorage.GetPublicUrl that this has been changed between the versions and that the problem came with this change.
This is a bit critical error, since we're up on .NET 6.0 and thereby forced to use 10.0.x of Piranha and we cannot downgrade from .NET 6.
EDIT:
It seems that this PR broke the SAS possibility. I cannot use managed identity here, we need to have SAS possibility...
The text was updated successfully, but these errors were encountered: