diff --git a/Helpers/YYUpload.cs b/Helpers/YYUpload.cs
index bacbe99..c1ef58f 100644
--- a/Helpers/YYUpload.cs
+++ b/Helpers/YYUpload.cs
@@ -74,18 +74,29 @@ namespace YYApi.Helpers
{
bt = Convert.FromBase64String(base64);
}
+ var fn = fileName + (string.IsNullOrEmpty(ext) ? string.Empty : $".{ext}");
+ return WriteFile(filePath, fn, bt);
+ }
+ ///
+ /// 把数据写入文件
+ ///
+ ///
+ ///
+ ///
+ ///
+ public YYUploadInfo WriteFile(string filePath, string fileName, byte[] data)
+ {
var realPath = Directory.GetCurrentDirectory() + "/wwwroot" + filePath;
if (!Directory.Exists(realPath))
{
Directory.CreateDirectory(realPath);
}
- var fn = fileName + (string.IsNullOrEmpty(ext) ? string.Empty : $".{ext}");
- File.WriteAllBytes(realPath + fn, bt);
+ File.WriteAllBytes(realPath + fileName, data);
return new YYUploadInfo
{
- Path = filePath + fn,
- Size = bt.Length
+ Path = filePath + fileName,
+ Size = data.Length
};
}
}
diff --git a/YYApi.csproj b/YYApi.csproj
index ba88af9..f5a31d0 100644
--- a/YYApi.csproj
+++ b/YYApi.csproj
@@ -23,8 +23,8 @@
-
-
+
+