I download blob content from Azure blob storage using OpenReadAsync() and trying to read the same using Read(). File is being changed (new content is getting appended to the file) at the same time while it is being downloaded.
I get error in the below Read() line. Which I believe is because of mismatch eTag values as it both reads and writes to blob content at the same time.
try
{
using (var stream = await blob.OpenReadAsync(offset, segmentSize))
{
stream.Position = offset;
stream.Read(buffer, 0, buffer.Length); // ERROR in this line
ret.Byte = buffer;
}
}
Here, I am trying to set conditional header ETag value as "*". As I want it to ignore 'mismatch' and 'match' of ETag values and not throw exception.
When i give IfMatch = "*", says cannot implicitly convert string to Azure.ETag. Please see code below.
Using Azure.Storage.Blobs package.
originalETag = properties.ETag;
blobOpenReadOptions = new BlobOpenReadOptions(true)
{
Conditions = new BlobRequestConditions()
{
IfMatch = "*"
//IfNotMatch = originalETag
}
};
And use blobOpenReadOptions
as below
using (var stream = await blob.OpenReadAsync(offset, segmentSize))
{
await blob.OpenReadAsync(blobOpenReadOptions);
stream.Position = offset;
stream.Read(buffer, 0, buffer.Length);
ret.Byte = buffer;
}
How do I assign IfMatch to *. Thank you.
CodePudding user response:
Not sure, but you are looking for this? You can not assign a String value to an ETag
IfMatch = new ETag("*")