Try your search with a different keyword or use * as a wildcard.
using System.Text.RegularExpressions;
using Microsoft.AspNetCore.Http;
using Nop.Core;
using Nop.Core.Infrastructure;
namespace Nop.Services.Media.RoxyFileman;
public partial class RoxyFilemanService : IRoxyFilemanService
{
#region Fields
protected readonly IRoxyFilemanFileProvider _fileProvider;
protected readonly IWorkContext _workContext;
#endregion
#region Ctor
public RoxyFilemanService(
IRoxyFilemanFileProvider fileProvider,
IWorkContext workContext)
{
_fileProvider = fileProvider;
_workContext = workContext;
}
#endregion
#region Utilities
///
/// Check whether there are any restrictions on handling the file
///
/// Path to the file
///
/// The result contains true if the file can be handled; otherwise false
///
protected virtual bool CanHandleFile(string path)
{
var result = false;
var fileExtension = Path.GetExtension(path).Replace(".", string.Empty).ToLowerInvariant();
var roxyConfig = Singleton.Instance;
var forbiddenUploads = roxyConfig.FORBIDDEN_UPLOADS.Trim().ToLowerInvariant();
if (!string.IsNullOrEmpty(forbiddenUploads))
result = !WhiteSpaceRegex().Split(forbiddenUploads).Contains(fileExtension);
var allowedUploads = roxyConfig.ALLOWED_UPLOADS.Trim().ToLowerInvariant();
if (string.IsNullOrEmpty(allowedUploads))
return result;
return WhiteSpaceRegex().Split(allowedUploads).Contains(fileExtension);
}
[GeneratedRegex("\\s+")]
private static partial Regex WhiteSpaceRegex();
#endregion
#region Configuration
///
/// Initial service configuration
///
/// The base path for the current request
/// A task that represents the asynchronous operation
public async Task ConfigureAsync(string pathBase)
{
var currentLanguage = await _workContext.GetWorkingLanguageAsync();
await _fileProvider.GetOrCreateConfigurationAsync(pathBase, currentLanguage.UniqueSeoCode);
}
#endregion
#region Directories
///
/// Delete the directory
///
/// Path to the directory
public void DeleteDirectory(string path)
{
_fileProvider.DeleteDirectory(path);
}
///
/// Download the directory from the server as a zip archive
///
/// Path to the directory
public byte[] DownloadDirectory(string path)
{
return _fileProvider.CreateZipArchiveFromDirectory(path);
}
///
/// Copy the directory
///
/// Path to the source directory
/// Path to the destination directory
public void CopyDirectory(string sourcePath, string destinationPath)
{
_fileProvider.CopyDirectory(sourcePath, destinationPath);
}
///
/// Create the new directory
///
/// Path to the parent directory
/// Name of the new directory
public virtual void CreateDirectory(string parentDirectoryPath, string name)
{
_fileProvider.CreateDirectory(parentDirectoryPath, name);
}
///
/// Get all available directories as a directory tree
///
/// Type of the file
/// List of directories
public IEnumerable