提交 5f8033a9 编写于 作者: I IanDavid

上传

上级 b760ea37
......@@ -14,29 +14,43 @@ using System.IO;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
namespace Ae.FileUpload.Api.Imp.Services
{
public class QiNiuService : IQiNiuService
{
private const string AccessKey = "_Igfnj2QmaHxXs****";//管理文件 认证
private const string SecretKey = "D9fhN79BqJwVsp****";//管理文件 认证
// private const string Domain = "https://m.aerp.com.cn";//文件管理 外链默认域名
private readonly IConfiguration _configuration;
private string AccessKey = "_Igfnj2QmaHxXs****";//管理文件 认证
private string SecretKey = "D9fhN79BqJwVsp****";//管理文件 认证
// private string Domain = "https://m.aerp.com.cn";//文件管理 外链默认域名
private string ImageDomain = "http://image.aerp.com.cn";
private string VideoDomain = "http://video.aerp.com.cn";
private bool useHttps = false;
private string ImageBucket = "aerp";//空间名,可以是公开或者私有的
private string VideoBucket = "video";
public QiNiuService()
public QiNiuService(IConfiguration configuration)
{
_configuration = configuration;
AccessKey = _configuration["Qiniu:AccessKey"];//管理文件 认证
SecretKey = _configuration["Qiniu:SecretKey"];
ImageDomain = _configuration["Qiniu:ImageDomain"];//文件管理 外链默认域名
VideoDomain = _configuration["Qiniu:VideoDomain"];
ImageBucket = _configuration["Qiniu:ImageBucket"];//空间名,可以是公开或者私有的
VideoBucket = _configuration["Qiniu:VideoBucket"];
useHttps = _configuration["Qiniu:UseHttps"]=="true";//是否使用HTTPS
// AK = ACCESS_KEY
// USE_HTTPS = (true|false) 是否使用HTTPS
// 使用前请确保AK和BUCKET正确,否则此函数会抛出异常(比如code612/631等错误)
Qiniu.Common.Config.AutoZone(AccessKey, ImageBucket, true);
Qiniu.Common.Config.AutoZone(AccessKey, VideoBucket, true);
Qiniu.Common.Config.AutoZone(AccessKey, ImageBucket, useHttps);
Qiniu.Common.Config.AutoZone(AccessKey, VideoBucket, useHttps);
}
//public Tuple<string, string> GetBucketAndHostByFileName(string fileName)
......
......@@ -8,6 +8,15 @@
"ApolloErpSql": "",
"ApolloErpSqlReadOnly": "",
"ToSwAlarmEamil": "devMonitor@ApolloErp.cn",
"Qiniu": {
"AccessKey": "-ZTwoPQR",
"SecretKey": "H75QaMXbnOnT1-",
"ImageDomain": "http://image.aerp.com.cn",
"VideoDomain": "http://video.aerp.com.cn",
"UseHttps": "false",
"ImageBucket": "aerp",
"VideoBucket": "video"
},
"ShopServer": {
"Domain": "http://192.168.3.252:8002/",
"GetShopInfo": "Demo/GetShopInfo",
......
......@@ -7,6 +7,15 @@
"AllowedHosts": "*",
"EnableSwagger": "false",
"ToSwAlarmEamil": "devMonitor@ApolloErp.cn",
"Qiniu": {
"AccessKey": "",
"SecretKey": "",
"ImageDomain": "https://m.aerp.com.cn",
"VideoDomain": "https://video.aerp.com.cn",
"UseHttps": "true",
"ImageBucket": "aerp",
"VideoBucket": "video"
},
"SkyWalking": {
"ServiceName": "Ae.FileUpload.Api",
"Namespace": "",
......
......@@ -7,6 +7,15 @@
"AllowedHosts": "*",
"EnableSwagger": "true",
"ToSwAlarmEamil": "devMonitor@ApolloErp.cn",
"Qiniu": {
"AccessKey": "",
"SecretKey": "",
"ImageDomain": "https://m.aerp.com.cn",
"VideoDomain": "https://video.aerp.com.cn",
"UseHttps": "true",
"ImageBucket": "aerp",
"VideoBucket": "video"
},
"SkyWalking": {
"ServiceName": "Ae.FileUpload.Api",
"Namespace": "",
......
......@@ -578,7 +578,7 @@ namespace Ae.Shop.Service.Imp.Services
+ DateTime.Now.Second.ToString()
+ DateTime.Now.Millisecond.ToString() + ".png";
fullName = "Shops/" + fileName;
fullName = "Shops/QRCode/" + fileName;
await _fileUploadClient.UploadBytes(new UploadByteRequest
{
Bytes = result.CodeBytes,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册