adam-werner / Our.Umbraco.StorageProviders.AWSS3

An implementation of the Umbraco IFileSystem connecting your Umbraco Media section to an AWS S3 Storage bucket featuring middleware serving up media files from the `/media` path and ImageSharp image provider/cache.
MIT License
17 stars 10 forks source link

UmbracoMediaPath not respected #13

Open ianleeder opened 1 year ago

ianleeder commented 1 year ago

I'm limited in my debugging capabilities, as I'm using a customer AWS account with SAML, so I've been unable to get this repo running locally to debug properly.

It appears that this project isn't observing the UmbracoMediaPath setting. In my project I have the setting "UmbracoMediaPath": "~/en-au/media", and that works fine on my local development. New media entries have a path set to /en-au/media/<random>/filename.ext.

However as soon as my code is deployed to AWS and uses this library, it can read and write to S3 just fine, but the paths are now /media/<random>/filename.ext.

Initially I thought this line was the issue:

builder.AddAWSS3FileSystem(AWSS3FileSystemOptions.MediaFileSystemName, "~/media",

But it seems to be a red-herring. The actual problem is in the GetUrl() method. Somehow it needs to use _rootUrl, but without debug capability I can't be confident enough to supply a PR.

ianleeder commented 1 year ago

I'm not sure why GetUrl needs to worry about the bucket path. For now I've made a local build with the method looking like this:

public string GetUrl(string path)
{
    return string.Concat(_rootUrl, "/", path);
}

And it seems to work, but there may be edge cases I'm not aware of.