new method ex ToBase64String
This commit is contained in:
		
							parent
							
								
									285ada3d13
								
							
						
					
					
						commit
						ef349eceb1
					
				| @ -2,7 +2,9 @@ | ||||
| { | ||||
|     public static class IFormFileExtensions | ||||
|     { | ||||
|         public static string ToBase64StringUrl(this IFormFile file) | ||||
|         public static string ToBase64StringUrl(this IFormFile file) => $"data:image/jpg;base64,{file.ToBase64String()}"; | ||||
| 
 | ||||
|         public static string ToBase64String(this IFormFile file) | ||||
|         { | ||||
|             if (file == null || file.Length == 0) | ||||
|             { | ||||
| @ -12,7 +14,7 @@ | ||||
|             using var memoryStream = new MemoryStream(); | ||||
|             file.CopyTo(memoryStream); | ||||
|             var fileBytes = memoryStream.ToArray(); | ||||
|             return $"data:image/jpg;base64,{Convert.ToBase64String(fileBytes)}"; | ||||
|             return Convert.ToBase64String(fileBytes); | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user