c# - The specified blob does not exist --even when the bob does exists -


with code below, getting error message:

the specified blob not exist

when debug code ,at .createblobcontainer -i can see specified bob got created ,then outside code manually copied , pasted text file blob.then when reach last line of code ,.downloadtostream ,it throws exception error saying specified blob doesnot exist. --even when bob exists

what's wrong sample code below:

        string testcontainername = "xyz"+common.generaterandomeightcharstring().tolower();          var testblobclient = blobclientfactory.createblobclient(true);         var testcontainer = blobclientfactory.createblobcontainer(testblobclient, testcontainername);         var zipoutputstream = new zipoutputstream(response.outputstream)         {             compressionlevel = compressionlevel.default         };         zipoutputstream.compressionlevel = compressionlevel.default;         zipoutputstream.enablezip64 = zip64option.asnecessary;         cloudblob testblob = testblobclient.getblobreference(testblobclient.baseuri.tostring() + testcontainername);         zipoutputstream.putnextentry(testcontainername);         blobrequestoptions options = new blobrequestoptions();         options.timeout = timespan.fromseconds(20.0);         testblob.downloadtostream(zipoutputstream, options); //exception error here 

here exception message .

microsoft.windowsazure.storageclient.storageclientexception unhandled user code   hresult=-2146233088   message=the specified blob not exist.   source=microsoft.windowsazure.storageclient   stacktrace:        @ microsoft.windowsazure.storageclient.tasks.task`1.get_result()        @ microsoft.windowsazure.storageclient.tasks.task`1.execute()        @ microsoft.windowsazure.storageclient.requestwithretry.requestwithretrysyncimpl[tresult](shouldretry retryoracle, synchronoustask`1 synctask)        @ microsoft.windowsazure.storageclient.taskimplhelper.executesynctaskwithretry[tresult](synchronoustask`1 synctask, retrypolicy policy)        @ microsoft.windowsazure.storageclient.cloudblob.downloadtostream(stream target, blobrequestoptions options)        @ ............................        @ system.web.mvc.actionmethoddispatcher.execute(controllerbase controller, object[] parameters)        @ system.web.mvc.reflectedactiondescriptor.execute(controllercontext controllercontext, idictionary`2 parameters)        @ system.web.mvc.controlleractioninvoker.invokeactionmethod(controllercontext controllercontext, actiondescriptor actiondescriptor, idictionary`2 parameters)        @ system.web.mvc.controlleractioninvoker.<>c__displayclass15.<invokeactionmethodwithfilters>b__12()        @ system.web.mvc.controlleractioninvoker.invokeactionmethodfilter(iactionfilter filter, actionexecutingcontext precontext, func`1 continuation)   innerexception: system.net.webexception        hresult=-2146233079        message=the remote server returned error: (404) not found.        source=system        stacktrace:             @ system.net.httpwebrequest.getresponse()             @ microsoft.windowsazure.storageclient.eventhelper.processwebresponsesync(webrequest req, eventhandler`1 handler, object sender)        innerexception:  

based on comment, see what's happening. creating blob container (think of folder) through code , manually copying file in container. url you're using blob (think of file) of container instead of file.

what need append name of file blob url. assuming, file manually copied in container named xyz.txt, create testblob object using code be:

cloudblob testblob = testblobclient.getblobreference(testblobclient.baseuri.tostring() + testcontainername + "/xyz.txt"); 

give try. should work.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -