new IFormFileExtensions
This commit is contained in:
		
							parent
							
								
									c766f1d0e9
								
							
						
					
					
						commit
						5873dba675
					
				| @ -0,0 +1,18 @@ | ||||
| namespace EnotaryoPH.Web.Common.Extensions | ||||
| { | ||||
|     public static class IFormFileExtensions | ||||
|     { | ||||
|         public static string ToBase64StringUrl(this IFormFile file) | ||||
|         { | ||||
|             if (file == null || file.Length == 0) | ||||
|             { | ||||
|                 throw new ArgumentNullException(nameof(file)); | ||||
|             } | ||||
| 
 | ||||
|             using var memoryStream = new MemoryStream(); | ||||
|             file.CopyTo(memoryStream); | ||||
|             var fileBytes = memoryStream.ToArray(); | ||||
|             return $"data:image/jpg;base64,{Convert.ToBase64String(fileBytes)}"; | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										1
									
								
								EnotaryoPH/EnotaryoPH.Web/Usings.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								EnotaryoPH/EnotaryoPH.Web/Usings.cs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1 @@ | ||||
| global using EnotaryoPH.Web.Common.Extensions; | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user