OrchardCMS / Orchard

Orchard is a free, open source, community-focused Content Management System built on the ASP.NET MVC platform.
https://orchardproject.net
BSD 3-Clause "New" or "Revised" License
2.37k stars 1.12k forks source link

Media Library: Can't migrate to Azure Blob Storage automatically #6756

Open BenedekFarkas opened 8 years ago

BenedekFarkas commented 8 years ago

Let's consider the following scenario:

I would expect the Media Library to continue to work as before, but media files are not loading at all for any folder, except "Recent". That's because Orchard stores the path of the media files based on their location on the file system (at the time they are created): NTFS uses \ as the directory separator, but AFS uses /, so when querying for content items in a specific folder while using AFS won't return any results for media items created on NTFS (and vice versa).

My suggestion is that Media Library should always use one of those (I don't think it matters which one, since both of them are illegal characters for file and folder names).

hannan-azam commented 8 years ago

@BenedekFarkas i agree with you, there should be a simple solution to migrate to Azure Blob/File System anytime one decides to go with either storage.

I came across this problem working on a project where the site involved around 6000 media items. We kept working happily with local file system and once we were ready to go live with Azure Blob Storage we got stuck with this. Later we solved it by running SQL Queries to convert all those directory separators to "/".

In HTML Content Editors and wherever media urls are used, Orchard uses URL based paths so "/" separator would be a good candidate for this.

sebastienros commented 8 years ago

I agree, the database should have normalized file paths, using '/' might be the simplest.

rtpHarry commented 8 years ago

Chrome latest

I'm using 1.10.x with Azure Media Storage module enabled and that new bit of code is failing:

image

image

It uploaded my kitty test pictures (I can see them in the blob) but now I can't view them.

Repro

This is an almost out of the box setup, I have cloned 1.10.x at 'b8e138b2d55734c9f6257d08fa944fb48b1676cb' then set up the azure settings and media to be stored in blob. Created a folder called 'cat pictures', dropped three pictures into it and tried to go back to media browser but all pages (folder page and recent page) are showing the display error.

rtpHarry commented 8 years ago

Hmm actually it only happens after I have uploaded and clicked "close".

When I navigate away from it (for example clicking on to Widgets admin page) and then click back to Media, everything works as expected.