public static async Task PutLocalFile(this IFileStoreService fileStoreService, string bucketName, string fileKey, string localFilePath) { using (var fileStream = new FileStream(localFilePath, FileMode.Open)) { await fileStoreService.PutStream(bucketName, fileKey, fileStream); } }
public static async Task PutContent(this IFileStoreService fileStoreService, string bucketName, string fileKey, string content) { using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(content ?? string.Empty))) { stream.Seek(0, SeekOrigin.Begin); await fileStoreService.PutStream(bucketName, fileKey, stream); } }
public static async Task PutJsonObject <T>(this IFileStoreService fileStoreService, string bucketName, string fileKey, T objectToStore) { using (var stream = new MemoryStream()) { await JsonSerializer.SerializeAsync(stream, objectToStore); stream.Seek(0, SeekOrigin.Begin); await fileStoreService.PutStream(bucketName, fileKey, stream); } }