-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Make media paths / urls mapping working under a virtual folder. #3200
Conversation
Update: this is my test that was wrong, so my above changes seem to be okay. Talking again about
So, if So, as said, right now, for |
Fixes #3195 |
@sebastienros returning back to this one.
|
@@ -79,17 +85,22 @@ public Task CreateFileFromStream(string path, Stream inputStream, bool overwrite | |||
|
|||
public string MapPathToPublicUrl(string path) | |||
{ | |||
return _publicUrlBase.TrimEnd('/') + "/" + this.NormalizePath(path); | |||
var publicUrl = new PathString(_publicUrlBase.TrimEnd('/') + "/" + this.NormalizePath(path)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Throws with Azure
Microsoft.AspNetCore.Http.PathString..ctor(String value)
The path in 'value' must start with '/'.
_publicUrlBase
is a full http URI like https://youraccount.blob.core.windows.net/media
Hi @jtkech, |
@TFleury thanks a lot for trying it!
I will rework on it asap and let you know when it will be ready to be checked. Thanks again. |
Maybe |
The next step could be branch the pipeline at 'media' path, move Pros :
Cons :
|
@TFleury thanks.
Good to know.
Okay.
So, how do you make the distinction between tenants. Do you mean the same media files are shared across tenants? Or am i missing something?
Yes i understand but the idea was to get all images through the
Oh, i thought it was already the case but anyway this is the case with non image media files that would be also stored on azure, as you said, we would need an
Yes, this was one of the goals.
Yes, i agree.
Yes, i saw this, the idea being that all images would be served through the Sorry to have bothered you, i will revert to 5941027 and if people ask for this, because it is not so obvious, i will open a new PR and take the time to try it with a real blob storage account. So, my 2 last questions are, how do you use it as it is if you have more than one tenant, do they share the same media files? Finally, how do you configure |
In my case blob storage is configured for each tenant, so each tenant have its own. I had not seen the things that way, and now I understand why you want to make the For the case of the URL If you use For those who wants to share the same AzureStorageAccount for multiple tenants, options are to have container or different 'BasePath' per tenant. |
@TFleury thanks for the infos.
Thanks for confirming this.
Okay.
Yes ;)
Okay, this is what i tried to do automatically by setting Anyway, because as you said there are pros and cons, i removed the changes related to azure. We will do another PR if people want to use the |
@sebastienros so, for infos i think this PR is ready. There is only one file changed to make |
I think this one is ready to be merged.
|
This is done by the
MediaFileStore
which is a tenant singleton. So, as i commented in the media startupConfigureServices()
where we define how to build it.Note: Normally, in
ConfigureServices()
the requestPathBase
doesn't contain yet the prefix (e.g only a virtual path). But a tenant may be built in a request context of another tenant, so herePathBase
would contain a prefix and of another tenant. The prefix is added just before executing the pipeline of a given tenant so it is there e.g in a startupConfigure()
.In
Media.Azure
, for thepublicUrlBase
of theMediaFileStore
we use an uri relying onMediaBlobStorageOptions
, and no distinction seems to be done between tenants by usingRequestUrlPrefix
. Maybe wrong or maybe intended to be defined per tenant by the config.So right now, for
Media.Azure
, to build theMediaFileStore
i just passed a nullIHttpContextAccessor
, at least here it works as before.