Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c4fb06163 | ||
|
|
e79ed47d39 |
@@ -41,7 +41,6 @@ namespace SimApi.Helpers
|
|||||||
|
|
||||||
ServeUrl = options.ServeUrl;
|
ServeUrl = options.ServeUrl;
|
||||||
Bucket = options.Bucket;
|
Bucket = options.Bucket;
|
||||||
Console.WriteLine($"{endpoint} == {options.AccessKey} == {options.SecretKey}");
|
|
||||||
var mcb = new MinioClient().WithEndpoint(endpoint)
|
var mcb = new MinioClient().WithEndpoint(endpoint)
|
||||||
.WithCredentials(options.AccessKey, options.SecretKey);
|
.WithCredentials(options.AccessKey, options.SecretKey);
|
||||||
if (useSsl)
|
if (useSsl)
|
||||||
@@ -71,12 +70,12 @@ namespace SimApi.Helpers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string UploadFile(string path, Stream stream)
|
public string UploadFile(string path, Stream stream,string contentType = "image/png")
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Mc.PutObjectAsync(new PutObjectArgs().WithBucket(Bucket).WithObject(path).WithStreamData(stream))
|
Mc.PutObjectAsync(new PutObjectArgs().WithBucket(Bucket).WithObject(path).
|
||||||
.Wait();
|
WithObjectSize(stream.Length).WithStreamData(stream).WithContentType(contentType)).Wait();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
catch (MinioException e)
|
catch (MinioException e)
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Text.Encodings.Web;
|
||||||
|
using System.Text.Json;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Text.Unicode;
|
||||||
|
|
||||||
namespace SimApi.Helpers
|
namespace SimApi.Helpers
|
||||||
{
|
{
|
||||||
@@ -36,5 +39,18 @@ namespace SimApi.Helpers
|
|||||||
|
|
||||||
return strbul.ToString();
|
return strbul.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 将对象序列化成JSON (控制台输出中文不会被编码)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="obj"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string Json(object obj)
|
||||||
|
{
|
||||||
|
return JsonSerializer.Serialize(obj, new JsonSerializerOptions
|
||||||
|
{
|
||||||
|
Encoder = JavaScriptEncoder.Create(UnicodeRanges.All)
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user