Forum Discussion

Octavian_Hornoi's avatar
Octavian_Hornoi
Icon for Nimbostratus rankNimbostratus
Jul 15, 2008

Renaming File In Transit

One of our partners is hosting a web page where users can select which songs (mp3s) they want to purchase and then after they purchase the mp3 they can click on a link and download them.

 

 

The problem we are running into is that each download link is a tokenized URL in our system such as:

 

 

http://download-ourdomain.com/GetFile?token=fjkl;d6y4re392fjfdkafdsa;

 

 

When the user receives the download, the filename in the browser is set to the token number and it looks like garbage (fjkl;d6y4re392fjfdkafdsa;.mp3). Obviously, we would like to fix this.

 

 

We were considering perhaps passing in an additional parameter to the BigIP that it could then interpret and rename the file in transit:

 

 

http://download-ourdomain.com/GetFile?filename=99_red_balloons.mp3&token=fjkl;d6y4re392fjfdkafdsa;

 

 

In this case, the BigIP would strip "filename=99_red_balloons.mp3" from the URL, request the file from the server behind it and then return the file to the requesting browser as "99_red_balloons.mp3".

 

 

Is this even possible? If it is, how would we go about doing it?

 

 

Thanks!

6 Replies

  • Hi,

     

     

    If you have the ability to instruct the app to insert a hidden parameter, couldn't you just change the app to use the actual filename for the links in the response content? The token could be included in the response as a hidden parameter or in the query string of a link. The app would need to validate that the token was valid.

     

     

    In other words, the app would send back a link in the page content or a redirect to:

     

     

    http://download-ourdomain.com/99_red_balloons.mp3?token=fjkld6y4re392fjfdkafdsa

     

     

    Aaron
  • We have custom code on our download servers written in perl that expects a method call of GetFile with a token. This cannot be altered due to other partners using this method already. We have to either change the name in transit or else, if we cannot do this via BigIP, we will have to have this new partner proxy our content. This is less desirable since it negates the whole point of having us as a download resource.

     

     

    Let's say for a moment that we were to take your suggestion. Could we take the link you show above:

     

     

    http://download-ourdomain.com/99_red_balloons.mp3?token=fjkld6y4re392fjfdkafdsa

     

     

    and modify it in the BigIP using a rule to pass it on to our download servers as:

     

     

    http://download-ourdomain.com/GetFile?token=fjkl;d6y4re392fjfdkafdsa;

     

     

    and then return the content result back to the requesting client's browser?

     

     

    If so, what would a rule like that look like?
  • Sure, you can do that with an iRule. The only thing changing from 'http://download-ourdomain.com/99_red_balloons.mp3?token=fjkld6y4re392fjfdkafdsa ' to 'http://download-ourdomain.com/GetFile?token=fjkl;d6y4re392fjfdkafdsa;' is the path. You can use HTTP::path to change this:

     
     when HTTP_REQUEST { 
      
         Check if requested object is an mp3 
         (or use some other criteria to determine when to rewrite the path 
        if {[HTTP::path] ends_with ".mp3"}{ 
      
           HTTP::path "/GetFile" 
        } 
     } 
     

    Aaron
  • And from the user's perspective in their browser, they would still see the URL as ending in .mp3 correct? After the content is returned that is.

     

     

    Sorry, I'm new to Irules and our network admin is out this week.
  • That's correct. The path is rewritten before the request is sent to the pool The browser address bar would get updated if instead you sent a redirect to the client to the /GetFile object.

     

     

    Aaron
  • Ok, this is great. We will test it today or tomorrow and see what results we get. Thanks for the quick, creative response.