Easy.Weboffice.Aliyun
1.0.0
dotnet add package Easy.Weboffice.Aliyun --version 1.0.0
NuGet\Install-Package Easy.Weboffice.Aliyun -Version 1.0.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="Easy.Weboffice.Aliyun" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Easy.Weboffice.Aliyun" Version="1.0.0" />
<PackageReference Include="Easy.Weboffice.Aliyun" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Easy.Weboffice.Aliyun --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Easy.Weboffice.Aliyun, 1.0.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.
#:package Easy.Weboffice.Aliyun@1.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Easy.Weboffice.Aliyun&version=1.0.0
#tool nuget:?package=Easy.Weboffice.Aliyun&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
简介
Easy.Weboffice.Aliyun 是一个基于 .NET 平台的在线文档编辑预览后台服务,是对阿里云IMM Weboffice的封装,封装了GenerateWebofficeToken和RefreshWebofficeToken方法。
快速开始
1. 注册服务
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddOpenApi();
builder.Services.AddWeboffice(builder.Configuration);
2. 配置文件
在 appsettings.json 中添加对应的配置节:
{
"Weboffice": {
"AccessKey": "your AccessKey", //OSS访问凭证AccessKey
"AccessKeySecret": "your AccessKeySecret", // OSS访问凭证AccessKeySecret
"Endpoint": "imm.cn-guangzhou.aliyuncs.com", //IMM服务访问域名
"OSSBucketName": "your oss bucket name", // OSS存储桶名称
"IMMProjectName": "your imm project name", // IMM项目名称
"Referer": "", //OSS防盗链,IMM 需要从 OSS 中获取源文件,如果 OSS 进行了防盗链设置,IMM 需要将对应的头部传给 OSS 才能获取源文件。
// 水印全局配置,前端可以覆盖该配置
"Watermark": {
"Enable": true, // 是否启用水印
"Value": "Easy.WebOffice", // 水印内容
"Rotate": 30, // 水印旋转角度
"Font": "bold 20px Serif" // 水印字体样式
},
// 文档权限全局配置,前端可以覆盖该配置
"Permission": {
"Rename": false, // 是否允许重命名
"ReadOnly": false, // 是否只读,pdf只能只读预览
"Print": true, // 是否允许打印
"Export": true, // 是否允许导出
"Copy": false // 是否允许复制
}
}
3. 使用服务
API示例(用于前端JS-SDK调用):
// 获取文档预览编辑凭证。
// 访问凭证过期时间为 30 分钟,需在访问凭证过期之前打开预览,过期后将无法预览。
app.MapPost("/getToken", async (WebofficeServiceRequest requset, [FromServices] IWebofficeService service) =>
{
var res = await service.GenerateWebofficeTokenAsync(requset);
if (res != null) return Results.Ok(res);
return Results.BadRequest("Failed to create weboffice edit session.");
});
// 刷新Weboffice访问凭证。
// Weboffice访问凭证有效期是30分钟,过期会失效,无法继续访问Weboffice。如果要继续访问Weboffice,可以使用这个接口刷新Weboffice访问凭证,即获取一个新的凭证,新的凭证过期时间也是30分钟。
// 刷新凭证过期时间为 1 天,需在刷新凭证过期之前调用刷新接口,过期后该凭证将会失效。
app.MapPost("/refeshToken", async (WebofficeRefeshTokenRequest requset, [FromServices] IWebofficeService service) =>
{
var res = await service.RefeshWebofficeTokenAsync(requset);
if (res != null) return Results.Ok(res);
return Results.BadRequest("Failed to refresh weboffice token.");
});
| 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.1
- AlibabaCloud.SDK.Imm20200930 (>= 4.7.2)
- Microsoft.Extensions.Caching.Memory (>= 10.0.1)
- Microsoft.Extensions.Configuration (>= 10.0.1)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.1)
- Microsoft.Extensions.DependencyInjection (>= 10.0.1)
- Microsoft.Extensions.Options (>= 10.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 257 | 12/25/2025 |