update package; add write file
This commit is contained in:
+15
-4
@@ -74,18 +74,29 @@ namespace YYApi.Helpers
|
|||||||
{
|
{
|
||||||
bt = Convert.FromBase64String(base64);
|
bt = Convert.FromBase64String(base64);
|
||||||
}
|
}
|
||||||
|
var fn = fileName + (string.IsNullOrEmpty(ext) ? string.Empty : $".{ext}");
|
||||||
|
return WriteFile(filePath, fn, bt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 把数据写入文件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filePath"></param>
|
||||||
|
/// <param name="fileName"></param>
|
||||||
|
/// <param name="data"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public YYUploadInfo WriteFile(string filePath, string fileName, byte[] data)
|
||||||
|
{
|
||||||
var realPath = Directory.GetCurrentDirectory() + "/wwwroot" + filePath;
|
var realPath = Directory.GetCurrentDirectory() + "/wwwroot" + filePath;
|
||||||
if (!Directory.Exists(realPath))
|
if (!Directory.Exists(realPath))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(realPath);
|
Directory.CreateDirectory(realPath);
|
||||||
}
|
}
|
||||||
var fn = fileName + (string.IsNullOrEmpty(ext) ? string.Empty : $".{ext}");
|
File.WriteAllBytes(realPath + fileName, data);
|
||||||
File.WriteAllBytes(realPath + fn, bt);
|
|
||||||
return new YYUploadInfo
|
return new YYUploadInfo
|
||||||
{
|
{
|
||||||
Path = filePath + fn,
|
Path = filePath + fileName,
|
||||||
Size = bt.Length
|
Size = data.Length
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -23,8 +23,8 @@
|
|||||||
<Folder Include="Exceptions\" />
|
<Folder Include="Exceptions\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="5.0.0" />
|
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="5.1.0" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="5.0.0" />
|
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="5.1.0" />
|
||||||
<PackageReference Include="HangFire.Core" Version="1.7.9" />
|
<PackageReference Include="HangFire.Core" Version="1.7.9" />
|
||||||
<PackageReference Include="Hangfire.AspNetCore" Version="1.7.9" />
|
<PackageReference Include="Hangfire.AspNetCore" Version="1.7.9" />
|
||||||
<PackageReference Include="Hangfire.Console" Version="1.4.2" />
|
<PackageReference Include="Hangfire.Console" Version="1.4.2" />
|
||||||
|
|||||||
Reference in New Issue
Block a user