Excel file (azure blob) does not download in chrome -


excel files stored in azure blob containers. downloaded without incident in ie in chrome page displays message (and in canary crashes):

this file appears corrupt 

and provides link download , point. i've tried setting content-type different excel formats result same.

here's blob code:

  memorystream memorystream = new memorystream();   createfile(memorystream, grid);   memorystream.position = 0;   var blockblob = container.getblockblobreference(randomfilename);   blockblob.properties.contenttype = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";   blockblob.deleteifexists();    var options = new blobrequestoptions()   {       servertimeout = timespan.fromminutes(10)    };     try    {             blockblob.uploadfromstream(memorystream, null, options);    }    catch (exception e)    {        _logger.error("uploading excel file: error: {0}",  e.message);    }      return new uri("https://myblobs.blob.core.windows.net/" + "containername/" + randomfilename); 

you missed blockblob.setproperties();

try this:

   var blockblob = container.getblockblobreference(randomfilename);    blockblob.deleteifexists();    blockblob.properties.contenttype =          "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";    blockblob.setproperties(); // commiting changes. 

note .xls files need set content-type application/vnd.ms-excel.

fyi: if want update property values in existing blob need fetch current values, set property want update , call setproperties on blob.

example:

    blob.fetchattributes();     blob.properties.contenttype = "image/png";     blob.setproperties(); 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -