6 changed files with 66 additions and 87 deletions
			
			
		- 
					6src/Shentun.Peis.Application/Books/HelloAAppService.cs
 - 
					67src/Shentun.Peis.Application/Books/QiNiuDemo.cs
 - 
					17src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs
 - 
					1src/Shentun.Peis.Application/Shentun.Peis.Application.csproj
 - 
					24src/Shentun.Peis.HttpApi.Host/Filter/JsonTimeSpanConverter.cs
 - 
					30src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs
 
@ -1,67 +0,0 @@ | 
				
			|||
using System; | 
				
			|||
using System.Collections.Generic; | 
				
			|||
using System.Linq; | 
				
			|||
using System.Text; | 
				
			|||
using System.Threading.Tasks; | 
				
			|||
using Volo.Abp.Application.Services; | 
				
			|||
using System.IO; | 
				
			|||
using Aliyun.OSS; | 
				
			|||
using System.Security.AccessControl; | 
				
			|||
 | 
				
			|||
namespace Shentun.Peis.Books | 
				
			|||
{ | 
				
			|||
 | 
				
			|||
 | 
				
			|||
    public static class QiNiuHelper | 
				
			|||
    { | 
				
			|||
 | 
				
			|||
        // 阿里云账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM
 | 
				
			|||
        // 用户进行API访问或日常运维,请登录RAM控制台创建RAM用户。
 | 
				
			|||
 | 
				
			|||
        const string accessKeyId = "LTAI5tBNDdiV7JudVvaQhU1t"; | 
				
			|||
        const string accessKeySecret = "sA6k0TbeX8w2cv7YhcTed7wyt0EBdN"; | 
				
			|||
 | 
				
			|||
        // yourEndpoint填写Bucket所在地域对应的Endpoint。以华东1(杭州)为例,Endpoint
 | 
				
			|||
        //  填写为https://oss-cn-hangzhou.aliyuncs.com。
 | 
				
			|||
        const string endpoint = "https://oss-cn-beijing.aliyuncs.com"; | 
				
			|||
  | 
				
			|||
        // 填写Bucket名称。
 | 
				
			|||
        const string bucketName = "whdshake"; | 
				
			|||
 | 
				
			|||
        public static void Upload_QiNiu() | 
				
			|||
        { | 
				
			|||
 | 
				
			|||
 | 
				
			|||
            // 填写Object完整路径。Object完整路径中不能包含Bucket名称。 
 | 
				
			|||
            // 即:objectName为文件上传到阿里云OSS上的文件夹路径
 | 
				
			|||
            var objectName = "imgae/222.png"; | 
				
			|||
 | 
				
			|||
            // 填写本地文件的完整路径。如果未指定本地路径,
 | 
				
			|||
            // 则默认从示例程序所属项目对应本地路径中上传文件。
 | 
				
			|||
            var localFilename = @"D:\aaa.png"; | 
				
			|||
 | 
				
			|||
            //System.Web.HttpContext.Current.Server.MapPath("imgae.png");
 | 
				
			|||
            // 创建OssClient实例。
 | 
				
			|||
            var client = new Aliyun.OSS.OssClient(endpoint, accessKeyId, accessKeySecret); | 
				
			|||
            try | 
				
			|||
            { | 
				
			|||
                // 上传文件。
 | 
				
			|||
                client.PutObject(bucketName, objectName, localFilename); | 
				
			|||
                Console.WriteLine("1"); | 
				
			|||
            } | 
				
			|||
            catch (Exception ex) | 
				
			|||
            { | 
				
			|||
                Console.WriteLine(ex.Message); | 
				
			|||
            } | 
				
			|||
 | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
     | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
 | 
				
			|||
 | 
				
			|||
 | 
				
			|||
 | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -0,0 +1,24 @@ | 
				
			|||
using System.Text.Json; | 
				
			|||
using System; | 
				
			|||
using System.Text.Json.Serialization; | 
				
			|||
 | 
				
			|||
namespace Shentun.Peis.Filter | 
				
			|||
{ | 
				
			|||
    /// <summary>
 | 
				
			|||
    /// 转换时间
 | 
				
			|||
    /// </summary>
 | 
				
			|||
    public class JsonTimeSpanConverter : JsonConverter<TimeSpan> | 
				
			|||
    { | 
				
			|||
        public override TimeSpan Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | 
				
			|||
        { | 
				
			|||
            var value = reader.GetString(); | 
				
			|||
            return TimeSpan.TryParse(value, out var timeSpan) ? timeSpan : new TimeSpan(); | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
        public override void Write(Utf8JsonWriter writer, TimeSpan value, JsonSerializerOptions options) | 
				
			|||
        { | 
				
			|||
            var timeSpanString = value.ToString(); | 
				
			|||
            writer.WriteStringValue(timeSpanString); | 
				
			|||
        } | 
				
			|||
    } | 
				
			|||
} | 
				
			|||
						Write
						Preview
					
					
					Loading…
					
					Cancel
						Save
					
		Reference in new issue