Jin.FileServer
1.1.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Jin.FileServer --version 1.1.0
NuGet\Install-Package Jin.FileServer -Version 1.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Jin.FileServer" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Jin.FileServer --version 1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Jin.FileServer, 1.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Jin.FileServer as a Cake Addin #addin nuget:?package=Jin.FileServer&version=1.1.0 // Install Jin.FileServer as a Cake Tool #tool nuget:?package=Jin.FileServer&version=1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
JinFileServer,可以让你在只保存一张原图的情况下, 无侵入的给现有.net core项目添加动态生成图片功能,可以生成任意大小哦。
1. 使用方法
1.1 配置
app.UseJinFileServer(env);
就是这么简单,一行代码搞定。
1.2 体验一把
保证项目wwwroot文件夹中有一张图片。
假设图片地址是:
https://localhost:44370/upload/201806/1.png
那么,使用浏览器访问:
https://localhost:44370/upload/201806/1.png_200x200.png
注:这样就会在原目录下面先生成名为1.png_200x200.png,大小为200x200的png文件, 然后输出到客户端!
再次访问这个地址,这个图片由于已存在,将直接输出到客户端浏览器。
2.图片生成参数
一个受JinFileServer托管的地址由:原图地址+图片生成参数构成。
2.1 图片生成参数格式:
_宽度 x 高度 扩展名
如:_200x200.png
完整地址如下:
https://localhost:44370/upload/201806/1.png_200x200.png
3. 配置说明
3.1 指定图片扩展名
app.UseJinFileServer(env, opt => {
opt.ImageFormats= new List<string> {
".bmp", ".gif", ".jpg", ".jpeg", ".png"
};
});
注:也是默认值。 以上配置的扩展名,在访问的时候,会自动被JinFileServer托管,当访问的地址带有以上后缀时,且带有图片生成参数,那么JinFileServer会自动生成指定要求的图片。
3.2 指定可生成的图片尺寸
app.UseJinFileServer(env, opt => {
opt.ImageSizes = new List<Size>
{
new Size(80, 80),
new Size(100, 100),
new Size(200, 200),
new Size(480, 480),
new Size(500, 500),
new Size(600, 600),
new Size(800, 800),
};
});
注:也是默认值。
没有配置的尺寸,在访问的时候,JinFileServer不会进行任何处理。
但是,如果没有配置任何尺寸,JinFileServer将允许生成任何大小的图片,慎用。
4. 记录
- 根据webp后缀,自动缩放文件大小 ags.jpg_500x500.jpg 加_是为了把真实路径区分开。
- 支持防盗链
- 支持一般文件,支持图片
- 支持设定某些尺寸可以设置为自动调整
5. 展望
下个版本,可支持防盗链。
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.1 is compatible. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETCoreApp 2.1
- Microsoft.AspNetCore.All (>= 2.1.0)
- SixLabors.ImageSharp (>= 1.0.0-beta0004)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.