I want to upload / create a file in an Azure Blob File Share step by step as I don't know the total amount of data to write (reading from a database line by line):
ShareClient share = new ShareClient(targetBlobStorageConnectionString, directoryName);
share.CreateIfNotExists();
ShareDirectoryClient directory = share.GetDirectoryClient("");
ShareFileClient file = directory.GetFileClient(fileName);
The problem is: If I create the file (or want to write it with overwrite=true) I've to state the maxLength - that I don't known.
var fileStream = file.OpenWrite(overwrite:false,position:0);
...
while(read) {
var data = System.Text.Encoding.UTF8.GetBytes(GetNewLine(...)+ "\n");
fileStream.Write(data, 0, data.Length);
}
fileStream.Close();
I hoped to resize the file with every line I write, but this isn't possible with a ShareFileClient.
Are there any other ways to write a file to Azure Blob File Share line by line?