72 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			C#
		
	
	
			
		
		
	
	
			72 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			C#
		
	
	
| using IRaCIS.Core.Domain.Share;
 | |
| using Microsoft.AspNetCore.Builder;
 | |
| using Microsoft.AspNetCore.Hosting;
 | |
| using Microsoft.Extensions.FileProviders;
 | |
| using System.IO;
 | |
| 
 | |
| namespace IRaCIS.Core.API
 | |
| {
 | |
|     public static class IRacisHostFileStore
 | |
|     {
 | |
| 
 | |
|         public static void UseIRacisHostStaticFileStore(this IApplicationBuilder app, IWebHostEnvironment env)
 | |
|         {
 | |
| 
 | |
|             var uploadPath = Path.Combine(Directory.GetParent(env.ContentRootPath.TrimEnd('\\')).FullName, StaticData.UploadFileFolder);
 | |
|             var dicomPath = Path.Combine(Directory.GetParent(env.ContentRootPath.TrimEnd('\\')).FullName, StaticData.TrialDataFolder);
 | |
| 
 | |
|             var comonPathPath = Path.Combine(Directory.GetParent(env.ContentRootPath.TrimEnd('\\')).FullName, StaticData.CommonFileFolder);
 | |
| 
 | |
|             var systemNoticePath = Path.Combine(Directory.GetParent(env.ContentRootPath.TrimEnd('\\')).FullName, StaticData.SystemNoticeFolder);
 | |
| 
 | |
| 
 | |
|             if (!Directory.Exists(uploadPath))
 | |
|             {
 | |
|                 Directory.CreateDirectory(uploadPath);
 | |
|             }
 | |
| 
 | |
|             if (!Directory.Exists(dicomPath))
 | |
|             {
 | |
|                 Directory.CreateDirectory(dicomPath);
 | |
|             }
 | |
| 
 | |
|             if (!Directory.Exists(systemNoticePath))
 | |
|             {
 | |
|                 Directory.CreateDirectory(systemNoticePath);
 | |
|             }
 | |
| 
 | |
| 
 | |
|             if (!Directory.Exists(comonPathPath))
 | |
|             {
 | |
|                 Directory.CreateDirectory(comonPathPath);
 | |
|             }
 | |
| 
 | |
|             app.UseStaticFiles(new StaticFileOptions
 | |
|             {
 | |
|                 FileProvider = new PhysicalFileProvider(uploadPath),
 | |
|                 RequestPath = $"/{StaticData.UploadFileFolder}"
 | |
|             });
 | |
| 
 | |
| 
 | |
|             app.UseStaticFiles(new StaticFileOptions
 | |
|             {
 | |
|                 FileProvider = new PhysicalFileProvider(dicomPath),
 | |
|                 RequestPath = $"/{StaticData.TrialDataFolder}"
 | |
|             });
 | |
| 
 | |
|             app.UseStaticFiles(new StaticFileOptions
 | |
|             {
 | |
|                 FileProvider = new PhysicalFileProvider(systemNoticePath),
 | |
|                 RequestPath = $"/{StaticData.SystemNoticeFolder}"
 | |
|             });
 | |
| 
 | |
| 
 | |
|             app.UseStaticFiles(new StaticFileOptions
 | |
|             {
 | |
|                 FileProvider = new PhysicalFileProvider(comonPathPath),
 | |
|                 RequestPath = $"/{StaticData.CommonFileFolder}"
 | |
|             });
 | |
|         }
 | |
|     }
 | |
| }
 |