Responsive File Manager running on .NET Core with Peachpie
If you are not already using Peachpie for anything, then including Responsive File Manager is very easy:
Get the ResponsiveFileManager.AspNetCore NuGet package from: https://www.nuget.org/packages/ResponsiveFileManager.AspNetCore/
Add the following to your appsettings.json:
"ResponsiveFileManagerOptions": {
// Path from base_url to base of upload folder. Use start and final /
"UploadDirectory": "/Media/Uploads/",
// Relative path from filemanager folder to upload folder. Use final /
"CurrentPath": "../Media/Uploads/",
// Relative path from filemanager folder to thumbs folder. Use final / and DO NOT put inside upload folder.
"ThumbsBasePath": "../Media/Thumbs/",
"MaxSizeUpload": 10
}
Configure
method:app.UseResponsiveFileManager();
ConfigureServices
method.services.AddResponsiveFileManager(options =>
{
});
/Misc/TinyMCE Plugin
.If you are wanting to use Peachpie for more than just ResponsiveFileManager, then it is recommended you ignore the ResponsiveFileManager.AspNetCore package, only acquire the base ResponsiveFileManager package and then manually configure the settings as follows:
Get the ResponsiveFileManager NuGet package from: https://www.nuget.org/packages/ResponsiveFileManager/
Create the following class:
public class ResponsiveFileManagerOptions
{
/// <summary>
/// Path from base_url to base of upload folder. Use start and final /
/// </summary>
public string UploadDirectory { get; set; }
/// <summary>
/// Relative path from filemanager folder to upload folder. Use final /
/// </summary>
public string CurrentPath { get; set; }
/// <summary>
/// Relative path from filemanager folder to thumbs folder. Use final / and DO NOT put inside upload folder.
/// </summary>
public string ThumbsBasePath { get; set; }
/// <summary>
/// Maximum upload size in Megabytes.
/// </summary>
public int? MaxSizeUpload { get; set; }
}
"ResponsiveFileManagerOptions": {
// Path from base_url to base of upload folder. Use start and final /
"UploadDirectory": "/Media/Uploads/",
// Relative path from filemanager folder to upload folder. Use final /
"CurrentPath": "../Media/Uploads/",
// Relative path from filemanager folder to thumbs folder. Use final / and DO NOT put inside upload folder.
"ThumbsBasePath": "../Media/Thumbs/",
"MaxSizeUpload": 10
}
Startup.cs
and ensure it looks something like this:public void ConfigureServices(IServiceCollection services)
{
// etc
// Adds a default in-memory implementation of IDistributedCache.
services.AddDistributedMemoryCache();
services.AddSession(options =>
{
options.IdleTimeout = TimeSpan.FromMinutes(30);
options.Cookie.HttpOnly = true;
});
// etc
}
public void Configure(IApplicationBuilder app)
{
// etc
app.UseSession();
var rfmOptions = new ResponsiveFileManagerOptions();
Configuration.GetSection("ResponsiveFileManagerOptions").Bind(rfmOptions);
app.UseDefaultFiles();
app.UseStaticFiles(); // shortcut for HostEnvironment.WebRootFileProvider
app.UseStaticFiles(new StaticFileOptions
{
RequestPath = new PathString("/filemanager"),
FileProvider = new PhysicalFileProvider(Path.GetFullPath(Path.Combine(Assembly.GetEntryAssembly().Location, "../filemanager"))),
});
app.UsePhp(new PhpRequestOptions(scriptAssemblyName: "ResponsiveFileManager")
{
BeforeRequest = (Context ctx) =>
{
ctx.Globals["rfm_options"] = PhpValue.FromClass(rfmOptions);
}
});
// etc
}
You can use the source code in this repo, as follows:
dotnet tool install -g Microsoft.Web.LibraryManager.Cli
libman restore
Startup.cs
file for configuration to copy to your own project to use with the NuGet package.If you find this project helpful, consider buying me a cup of coffee. :-)