RoxyFileman and Firefox

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
2 года назад
Open the RoxyFileman in the Firefox and you will see this error message (for each request)

XML Parsing Error: syntax error
Location: https://www.yourstore.com/Admin/RoxyFileman/ProcessRequest?a=DIRLIST&type=image
Line Number 1, Column 1:

Chrome doesn't have this issue.
The reason of this issue that Firefox wants to see "application/json" as a type of response. This response has a type "application/xml".
We need to add the type of response in the header if the response has JSON
Example

        public virtual async Task GetFilesAsync(string directoryPath, string type)
        {
            directoryPath = await GetVirtualPathAsync(directoryPath);
            var files = await GetFilesByDirectoryAsync(GetFullPath(directoryPath), type);
            GetHttpContext().Response.Headers.Add("Content-Type", "application/json");
            await GetHttpContext().Response.WriteAsync("[");
            for (var i = 0; i < files.Count; i++)
2 года назад
and several improvements for performance if the folder has 1000 and more pictures:

Change the method GetFilesByDirectoryAsync
old code
            var files = new List<string>();
            foreach (var fileName in _fileProvider.GetFiles(directoryPath))
                if (string.IsNullOrEmpty(type) || GetFileType(_fileProvider.GetFileExtension(fileName)) == type)
                    files.Add(fileName);
            return files;

new code
            return _fileProvider.EnumerateFiles(directoryPath, "*.*")
                    .AsParallel()
                    .Where(file => string.IsNullOrEmpty(type) || GetFileType(_fileProvider.GetFileExtension(file)) == type)
                    .ToList();


and very important fix (1000 pictures 40sec, after fix 0.5sec)
change the method GetFilesAsync
old code
using var image = SKBitmap.Decode(stream);
                                            width = image.Width;
                                            height = image.Height;

new  code (we need to read only bitmap header)
                                       var image = SKBitmap.DecodeBounds(stream);
                                            width = image.Width;
                                            height = image.Height;
2 года назад
Thanks a lot, Alexander! We'll fix it soon - https://github.com/nopSolutions/nopCommerce/issues/5894
2 года назад
Hi, Alexander. Thank you for your help. We fixed the issue and made performance changes which you recommended. For more details please see the following commits: 30fd49ce and 78a0bcea
2 года назад
Thank you
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.