Пример #1
0
 public static async Task <T> GetJsonObject <T>(this IFileStoreService fileStoreService, string bucketName, string fileKey)
 {
     using (var stream = await fileStoreService.GetStream(bucketName, fileKey))
     {
         return(await JsonSerializer.DeserializeAsync <T>(stream));
     }
 }
Пример #2
0
 public static async Task SaveToLocalFile(this IFileStoreService fileStoreService, string bucketName, string fileKey, string localFilePath)
 {
     using (var fileStream = new FileStream(localFilePath, FileMode.CreateNew))
     {
         using (var stream = await fileStoreService.GetStream(bucketName, fileKey))
         {
             await stream.CopyToAsync(fileStream);
         }
     }
 }
Пример #3
0
 public static async Task <string> GetContent(this IFileStoreService fileStoreService, string bucketName, string fileKey)
 {
     using (var stream = await fileStoreService.GetStream(bucketName, fileKey))
     {
         using (var reader = new StreamReader(stream, Encoding.UTF8))
         {
             return(await reader.ReadToEndAsync());
         }
     }
 }