c# - Azure blob storage download file instead of opening in the browser -


i uploading files azure blob storage using code, container cloudblobcontainer

    public void savefile(string blobpath, stream stream)     {         stream.seek(0, seekorigin.begin);         cloudblockblob blockblob = container.getblockblobreference(virtualpath);          blockblob.properties.contentdisposition =  "attachment; filename=" + path.getfilename(virtualpath);          blockblob.uploadfromstream(stream);     } 

then when user clicks on file in web page trying trigger download prompted either save/open file. calling action returns redirect blob url.

    public actionresult loadfile(string path)     {             string url = storagemanager.getbloburlfromname(path);         return redirect(url);     } 

the issue open files in browser e.g. user redirect away site , shown .jpg file in browser when expecting them stay on page start downloading file.

one way achieve want mvc action fetch image blob storage , return file, ie:

public actionresult loadfile(string path) {         bytearray imagebytes = ....get img blob storage     return file(bytearray, "image/png", "filename.ext"); } 

Comments

Popular posts from this blog

symfony - TEST environment only: The database schema is not in sync with the current mapping file -

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -