Mediaselector: The given path's format is not supported

Kenny Deblaere asked on March 1, 2017 15:58

Hello

I'm having problems when my folder-list in the media selector is bigger than my Max subfolders: setting.

In my code: I'm getting following error:

Message: Exception of type 'System.Web.HttpUnhandledException' was thrown., which is followed by Message: The given path's format is not supported..

The last error happens in the Kentico MediaView file, at following function:

public string GetItemUrl(MediaFileInfo fileInfo, SiteInfo site, Guid fileGuid, 
      string fileName, string fileExtension, string filePath, 
      bool isPreview, int height, int width, int maxSideSize)
{
    string result;
    bool resize = (maxSideSize > 0);

    fileName = UsePermanentUrls ? AttachmentHelper.GetFullFileName(fileName, fileExtension) : fileName;

    ...

    if ((Config != null) && (Config.UseFullURL || generateFullURL 
        || (SiteContext.CurrentSiteID != LibraryInfo.LibrarySiteID) 
        || (SiteContext.CurrentSiteID != GetCurrentSiteId())))
    {
        // If permanent URLs should be generated
        ...
    }
    else
    {
        if (UsePermanentUrls || resize || isPreview)
        {
            ...
        }
        else
        {
            if (fileInfo != null)
            {
                result = MediaFileURLProvider.GetMediaFileUrl(fileInfo, 
                    SiteContext.CurrentSiteName, LibraryInfo.LibraryFolder);
            }
            else
            {
                // URL in format '/cms/EcommerceSite/media/testlibrary/folder1/testfile.gif'
                result = MediaFileURLProvider.GetMediaFileUrl(SiteContext.CurrentSiteName, 
                    LibraryInfo.LibraryFolder, filePath);
            }
        }
    }

    ...
}

The error occures in the last else statement, at this line:

// URL in format '/cms/EcommerceSite/media/testlibrary/folder1/testfile.gif'
result = MediaFileURLProvider.GetMediaFileUrl(SiteContext.CurrentSiteName, 
    LibraryInfo.LibraryFolder, filePath);

Some things I've noticed searching for the problem:

  1. When opening a folder with images, the filePath variable is a relative image path, just as stored in the database.
  2. When I click in the list on click here for more, the filepath is an absolute path, with <projectlocation>/cms/media/folder.
  3. It makes sense the folder isn't found, because I store my images on a blob storage, as I'm running my application on Azure.

The location of my blob storage is the same as my web application, it's West-Europe.

How can I fix this error, and another issue, speed up the Media Libary Picker?

Kind regards

Kenny

   Please, sign in to be able to submit a new answer.