locked
Using Shared Access Signature but change file name RRS feed

  • Question

  • I have files stored in a private container that I want to give a user temporary access to. So I can easily use a Shared Access Signature. However I have one glitch, the files as they exist in bob storage use internal names and I would like the user downloading it to see a friendly name.

    Is there any way to do this while still serving the file directly from blob storage (as opposed to streaming it through my web server)?

    Saturday, April 6, 2013 4:46 PM

All replies

  • Maybe you can copy and rename them for the period your signatures should be valid. Without any involvement of a server this won't work.

    Using a URLrerouter might also be an option. This could redirect users from yourdomain.com/files/filex to the blob URL.


    Never miss the latest Windows Azure news on http://blogs.msdn.com/b/windowsazure/

    Sunday, April 7, 2013 6:57 AM
  • Unfortunately some of these files are quite large (250MB or larger) so a copy is not only wasteful but would be slow. Thanks for the thought.

    Anyone else have any ideas?

    Monday, April 8, 2013 10:48 PM
  • Hi,

    For the public container, you may set the Content-Disposition in header as a friendly name, but I am not sure it works in private one or not.

    http://blog.degree.no/2012/04/downloading-blobs-from-windows-azure/

    It seems no way to do it.

    Thanks,


    QinDian Tang
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, April 9, 2013 5:00 AM
  • What about the URLRetouring option I mentioned?

    Never miss the latest Windows Azure news on http://blogs.msdn.com/b/windowsazure/

    Tuesday, April 9, 2013 7:46 AM
  • Yes I really like the content-disposition idea but it still requires that I stream the file through my web server. Is there any way to get blob storage to set this header so I can stream directly from there?
    Tuesday, April 9, 2013 2:16 PM
  • It's not really clear to me how URLRerouting would work? Are you familiar with this technique? Could I set up a url on the fly that is a local resource (say http://mysite.com/path/friendlyfile.zip) that somehow is simple an url to a blob storage file (which included a SAS)?

    It sounds promising but the mechanics escape me.

    Tuesday, April 9, 2013 2:19 PM
  • Let me try this out and come back to you with some code. Hang on...

    Never miss the latest Windows Azure news on http://blogs.msdn.com/b/windowsazure/

    Tuesday, April 9, 2013 10:13 PM
  • So the idea I had in mind is quite simple, maybe to simple for your scenario, but lets give it a try.

    If you take, for example, a ASP.NET MVC app where you define this ActionResult:

    public ActionResult GetMeMyFile(string fileName = "myfile.zip") {

    //Create SAS for myfile.zip blob the user requested. return Redirect("https://[blobaccount].blob.core.windows.ne.......[SAS]"); }


    In you global.asax you define the route (the friendly URL) your users can navigate to:

    public static void RegisterRoutes(RouteCollection routes)
            {
                routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    
                           routes.MapRoute(
                    "Parameter",
                    "{controller}/{action}/{filename}",
                    new { controller = "Home", action = "GetMeMyFile", filename = ""}
            );
    
            }

    Mark that with this approach the user sees the blob.core.... url after he has been redirected. This does contradict with your initial question but I don't know if that is a show-stopper for you.


    Never miss the latest Windows Azure news on http://blogs.msdn.com/b/windowsazure/

    Wednesday, April 10, 2013 7:39 AM
  • I appreciate the sample Valery. I am not an MVC guy though so the syntax is really tripping me up in experimenting. Could the same be accomplished in WebForms?
    Wednesday, April 10, 2013 4:14 PM
  • Yes, this should work as of ASP.NET 3.5 sp1 as stated in this post here.

    Never miss the latest Windows Azure news on http://blogs.msdn.com/b/windowsazure/


    Wednesday, April 10, 2013 6:25 PM
  • Did it work for you in Webforms?

    Never miss the latest Windows Azure news on http://blogs.msdn.com/b/windowsazure/

    Tuesday, April 16, 2013 10:55 AM
  • No this approach does not suit my needs because I am still generating a SAS to the blob file whose name I don;t want to expose. The Redirect() does not serve the filename up as I would like it only allows the user to see a nice looking link, but the browser still uses the original filename on the actual download.
    Thursday, April 18, 2013 11:40 PM