Friday, 15 June 2012

azure - Invalid character exception when adding Metadata to a CloudBlob -



azure - Invalid character exception when adding Metadata to a CloudBlob -

task

upload file azure blob storage original filename , assign filename meta-data cloudblob

problem

these characters not permitted in meta-data acceptable blob name:

š Š ñ Ñ ç Ç ÿ Ÿ ž Ž Ð œ Œ « » éèëêð ÉÈËÊ àâä ÀÁÂÃÄÅ àáâãäå ÙÚÛÜ ùúûüµ òóôõöø ÒÓÔÕÖØ ìíîï ÌÍÎÏ question is there way store these characters in meta-data? missing setting causes exception? most of these characters standard glyphs in languages, how handle that? is there documentation available advises issue? found blob , meta-data naming conventions, none info itself! code var dirtyfilename = file.filename; var normalizedfilename = file.filename.cleanoffdiacriticandnonascii(); // blob name accepts characters acceptable filenames in windows var blob = container.getblobreference(dirtyfilename); //upload content blob, create blob if not exist. blob.metadata["filename"] = normalizedfilename; blob.attributes.properties.contenttype = file.contenttype; // error: occurs here! blob.uploadfromstream(file.inputstream); blob.setmetadata(); blob.setproperties(); error

references naming , referencing containers, blobs, , metadata how back upwards other languages in azure blob storage? how remove diacritics (accents) string in .net? azure cloudblob setmetadata fails "the metadata specified invalid. has characters not permitted." replacing characters in c# (ascii) workarounds

illegal characters in filename tip of ice-berg, magnified purpose of question! bigger image index these files using lucene.net , such need lot of meta-data stored on blob. please don't suggest storing separately in database, don't! until have been lucky have come across 1 file diacritic characters!

so, @ moment making effort avoid saving filename in meta-data workaround!

just have had confirmation azure-sdk-for-net team on github ascii characters valid info within blob meta-data.

joeg commented: supported characters in blob metadata must ascii characters. work around can either escape string ( percent encode), base64 encode etc.

source on github

so work-around, either:

escape string (percent encode), base64 encode, etc, suggested joeg use techniques have mentioned in other answer.

azure character-encoding windows-azure-storage azure-storage-blobs

No comments:

Post a Comment