Skip to content
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

Issue when bucket prefix is a sub-folder #7

Open
Attackmonkey opened this issue Dec 1, 2020 · 2 comments
Open

Issue when bucket prefix is a sub-folder #7

Attackmonkey opened this issue Dec 1, 2020 · 2 comments

Comments

@Attackmonkey
Copy link

Attackmonkey commented Dec 1, 2020

If you have the media stored in anything more than one level deep, we get some interesting issues. In our client's environment, several sites share a bucket, and they store the files like /project-name/media/.

In the web.config file we set the prefix like so:

<add key="BucketFileSystem:MediaPrefix" value="PR1802/media" />

When we UPLOAD the media in the back office, the files upload to the bucket OK, but the media files are stored in Umbraco as /PR1802/media/asdasdasd/myfile.jpg, which obviously means they break in the back office. If you go to the URL, and manually remove the /PR1802 part, the image is loaded by the virtual file system as expected.

Is there a way to get this to work? I can hack my way round it with IIS rewrites and a custom media URL provider for the front end, but it would be good if this could be made to work out of the box.

To Replicate:

  • Configure the site to use the virtual file provider, so images appear on the site URL
  • Create a folder in your S3 bucket, add a media folder inside it
  • Set that as the media prefix in the web.config to your site, e.g. "myfolder/media"
  • Navigate to the media section of the back office, and upload a file
  • Check in the bucket that the file has uploaded correctly
  • Reload the media page in the back office, the image will have disappeared
  • Go to the info tab, click on the image link, and it will be broken
  • Remove the folder before the "media" part and the image will render
@Attackmonkey
Copy link
Author

Additional info, even if you have only a single level and you don't use "media" as the prefix, things break. For example, using the virtual media provider:

  • Set the prefix to "TEST"
  • Upload an image to the backoffice
  • It will be uploaded to the bucket fine
  • However, reload the media edit page and the image is gone
  • Go to the info tab and you'll see the link is linking to "/TEST/ghfgfg/myfile.jpg", which obviously doesn't work
  • You can get the file to work by changing the URL in the browser to replace the /TEST/ part with /media/ and it will work

It seems like there's some issue between Umbraco and the S3 provider. If we're serving up the image on "/media/ghfgfg/myfile.jpg", I'd expect what's in the database against the media to match that, or for the link that IS saved to actually work.

Looking at the code, the bit that configures the virtual path provider seems to be hard coded to "media".

@Attackmonkey
Copy link
Author

OK, the main issue seems to be that the virtual path provider always resolves to "/media". If you have it use the bucket prefix like the older V7 one did, and set up a folder with the same path with the special web.config in like you would have with the normal /media paths, then everything works as expected, albeit the local paths have to match the bucket one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant