Buffered enumerables with AzureSDK
In v0.1.0, upload_stream/4 and download_stream/4 accept enumerables but buffer
content in memory. Chunked streaming is planned for a future release.
Mix.install([
{:azure_sdk, path: Path.expand("..", __DIR__)}
])
credential =
AzureSDK.Identity.SharedKeyCredential.new(
"devstoreaccount1",
"Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="
)
client =
AzureSDK.Storage.Client.new(
account: "devstoreaccount1",
credential: credential,
endpoint: "http://127.0.0.1:10000/devstoreaccount1"
)
container = "stream-demo"
{:ok, _} = AzureSDK.Storage.Container.create(client, container)
Stream upload
stream = Stream.repeatedly(fn -> "chunk" end) |> Stream.take(3)
{:ok, _} = AzureSDK.Storage.Blob.upload_stream(client, container, "chunks.bin", stream)
Stream download
{:ok, stream} = AzureSDK.Storage.Blob.download_stream(client, container, "chunks.bin")
stream |> Enum.join()