Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
801f698dcf | ||
|
|
9c939426ba |
+20
-17
@@ -56,34 +56,37 @@ namespace SimApi.Helpers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取上传的URL
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <param name="expire"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public string GetUploadUrl(string path, int expire = 7200)
|
public string GetUploadUrl(string path, int expire = 7200)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
return Mc.PresignedPutObjectAsync(new PresignedPutObjectArgs().WithBucket(Bucket)
|
return Mc.PresignedPutObjectAsync(new PresignedPutObjectArgs().WithBucket(Bucket)
|
||||||
.WithObject(path).WithExpiry(expire)).Result;
|
.WithObject(path).WithExpiry(expire)).Result;
|
||||||
}
|
}
|
||||||
catch (MinioException e)
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取下载的URL
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <param name="expire"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string GetDownloadUrl(string path, int expire = 600)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Error occurred: " + e);
|
return Mc.PresignedGetObjectAsync(new PresignedGetObjectArgs().WithBucket(Bucket).WithObject(path)
|
||||||
return e.Message;
|
.WithExpiry(expire)).Result;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string UploadFile(string path, Stream stream,string contentType = "image/png")
|
|
||||||
|
public string UploadFile(string path, Stream stream, string contentType = "image/png")
|
||||||
{
|
{
|
||||||
try
|
Mc.PutObjectAsync(new PutObjectArgs().WithBucket(Bucket).WithObject(path).WithObjectSize(stream.Length)
|
||||||
{
|
.WithStreamData(stream).WithContentType(contentType)).Wait();
|
||||||
Mc.PutObjectAsync(new PutObjectArgs().WithBucket(Bucket).WithObject(path).
|
|
||||||
WithObjectSize(stream.Length).WithStreamData(stream).WithContentType(contentType)).Wait();
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
catch (MinioException e)
|
|
||||||
{
|
|
||||||
Console.WriteLine("Error occurred: " + e);
|
|
||||||
return e.Message;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string FullUrl(string path)
|
public string FullUrl(string path)
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -198,7 +198,7 @@ namespace SimApi
|
|||||||
{
|
{
|
||||||
var options = builder.ApplicationServices.GetRequiredService<SimApiOptions>();
|
var options = builder.ApplicationServices.GetRequiredService<SimApiOptions>();
|
||||||
|
|
||||||
var logger = builder.ApplicationServices.GetRequiredService<ILogger>();
|
var logger = builder.ApplicationServices.GetRequiredService<ILogger<SimApiOptions>>();
|
||||||
|
|
||||||
if (options.EnableForwardHeaders)
|
if (options.EnableForwardHeaders)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user