电子签基础功能
This commit is contained in:
@@ -115,10 +115,26 @@ public class FileService : DbRepository<SysFile>, IFileService
|
||||
IFormFile file = new FormFile(stream, 0, content.Length, "file", fileName)
|
||||
{
|
||||
Headers = new HeaderDictionary(),
|
||||
ContentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
|
||||
ContentType = ResolveGeneratedContentType(fileName)
|
||||
};
|
||||
return await StorageFile(engine, file);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据归档文件扩展名设置 OSS 元数据,避免 PDF、ZIP 被错误标记为 DOCX。
|
||||
/// </summary>
|
||||
private static string ResolveGeneratedContentType(string fileName)
|
||||
{
|
||||
return Path.GetExtension(fileName).ToLowerInvariant() switch
|
||||
{
|
||||
".docx" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||
".pdf" => "application/pdf",
|
||||
".zip" => "application/zip",
|
||||
".png" => "image/png",
|
||||
".jpg" or ".jpeg" => "image/jpeg",
|
||||
_ => "application/octet-stream"
|
||||
};
|
||||
}
|
||||
#region 方法
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user