public async Task <Base64String> GetOrDefaultAsync(RawObjectType objectType, string objectId) { var containerName = RawObjectRepositoryTools.GetContainerName(_integrationName, objectType); var blobName = RawObjectRepositoryTools.GetBlobName(objectId); if (!await _blob.HasBlobAsync(containerName, blobName)) { return(null); } using (var stream = await _blob.GetAsync(containerName, blobName)) using (var textReader = new StreamReader(stream)) { stream.Position = 0; return(new Base64String(await textReader.ReadToEndAsync())); } }
public async Task SaveAsync(RawObjectType objectType, string objectId, Base64String rawObject) { await Task.CompletedTask; // TODO: Optimize and uncomment //var containerName = RawObjectRepositoryTools.GetContainerName(_integrationName, objectType); //var blobName = RawObjectRepositoryTools.GetBlobName(objectId); //using (var stream = new MemoryStream()) //using (var textWriter = new StreamWriter(stream)) //{ // textWriter.Write(rawObject.Value); // await textWriter.FlushAsync(); // await stream.FlushAsync(); // stream.Position = 0; // await _blob.SaveBlobAsync(containerName, blobName, stream); //} }
public static string GetContainerName(string integrationName, RawObjectType objectType) { return($"{integrationName}-raw-{objectType.ToString().CamelToKebab()}"); }