c# - Is it possible to force azure blob metadata to be overwritten on new blob when copying -


so copying blob blob , overwriting blob newblob following code:

copystatus copy = copystatus.pending; while (copy != copystatus.success) {     newblob.startcopyfromblob(blob);     copy = manager.checkisdonecopying(newblob, container.name); } 

newblob has metadata on before copy , here see that:

if no name-value pairs specified, operation copy source blob metadata destination blob. if 1 or more name-value pairs specified, destination blob created specified metadata, , metadata not copied source blob.

which gather means old blobs metadata not copied over. force original blob overwrite newblob's metadata , edit newblobs metadata using following:

 newblob.fetchattributes();  if (newblob.metadata.containskey(storagemanager.islive))  {        newblob.metadata[storagemanager.islive] = "y";  }  else  {        newblob.metadata.add(new keyvaluepair<string, string>(storagemanager.islive, "y"));  }  if (newblob.metadata.containskey(storagemanager.lastuploadedtime))  {        newblob.metadata[storagemanager.lastuploadedtime] = uploadedtime.ticks.tostring();  }  else  {        newblob.metadata.add(new keyvaluepair<string, string>(storagemanager.lastuploadedtime, uploadedtime.ticks.tostring()));  } 

is possible force overwrite of newblobs metadata old blob?

edit

if add line code:

  copystatus copy = copystatus.pending;   newblob.metadata.clear();   while (copy != copystatus.success)   {... 

the metadata copied over. though cannot way if copy operation fails or never finishes means have invalid newblob. there must better way this?

no, calling newblob.metadata.clear() before executing newblob.startcopyfromblob(blob) doesn't mean clearing newblob's metadata @ server side , start asynchronously blob copying. clear, newblob.metadata.clear() won't trigger real request server unless call newblob.setmetadata() then.

actually, calling newblob.metadata.clear() before executing newblob.startcopyfromblob(blob) means "not specifying key-value pair in copyblob request", mentioned saw msdn webpage.

therefore, solution perfect 1 expect, please verify again! :)


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -