We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here. 

Forum Discussion

Bob A.3's avatar
Bob A.3
New member | Level 2
9 years ago

Saving URL to act as a URL Redirect?

I would like to be able to make a share link to a Dropbox file that itself contains a URL such that when the user executes the first link in their browser the end result is that the URL stored in the DB file gets executed through the domino effect of link calling link.  How can I best accomplish this?

I tried using the DB feature where you can save a URL to dropbox.  That does not meet my needs because I need to be able to change the URL saved within the drop box file.

Can this be done with JavaScript or would I also need to use the DB api in order to parse the URL stored in the DB file?  The DB file will only contain the URL... so really it would not need to be parsed if... so would JavaScript be able to do the whole job?

  • Yes, just fire off a GET request (via ajax or fetch, or your favourite http lib) to the exact public url for the file.

    Ensure the file is structured as JSON, and you should be able to either directly read the response as JSON, or you may have to JSON.parse() it, and theres your data. 

    Then do your favourite JS redirect.

    The only issue is that the .html file which triggers all that cannot be stored on Dropbox as a public or shared link, it has to be stored elsewhere.

  • DaveC2's avatar
    DaveC2
    New member | Level 1

    Unless things have changed lately (and thats not impossible!), you would want to create a link to a html page that is stored in your dropbox, and that html page has a html redirector instruction.

  • Bob A.3's avatar
    Bob A.3
    New member | Level 2

     

    Dave,

    How it works for me now is ...

    1) User presses button with link to dropbox file

    2) link stored in that dropbox file shows up in clear text in the browser window

     

    I am hoping that I can store the redirector link in the drop box file such that...

    A) user presses button with link to dropbox file

    B) link stored in that dropbox file then auto executes and lands user on redirected page.

     

    Are you suggesting that I use some redirector html tag to accomplish this STEP B?

     

  • Richard P.'s avatar
    Richard P.
    Icon for Super User alumni rankSuper User alumni

    Dropbox is just about to stop allowing html files to be rendered via its shared links, so the HTML and Javascript route will be useless to you very very shortly as it will stop working.

    Why do you want to do this on Dropbox? Its a very small, quick project for a web developer and you could send proper 301/302/303 redirects.

  • Bob A.3's avatar
    Bob A.3
    New member | Level 2

    There is no server involved with regard to my html so 301's etc can't be used.

    Maybe I should ask the question this way...

    Can I use Javascript to download a file from drop box via a public link. (ie. person not logged into Dropbox) and ingest the data (link) stored in that file into a JavaScript variable?

     

    If I can do that then I can have the JavaScript then fire off that link that it got from the downloaded Dropbox file.

  • Richard P.'s avatar
    Richard P.
    Icon for Super User alumni rankSuper User alumni

    Yes, just fire off a GET request (via ajax or fetch, or your favourite http lib) to the exact public url for the file.

    Ensure the file is structured as JSON, and you should be able to either directly read the response as JSON, or you may have to JSON.parse() it, and theres your data. 

    Then do your favourite JS redirect.

    The only issue is that the .html file which triggers all that cannot be stored on Dropbox as a public or shared link, it has to be stored elsewhere.

About Create, upload, and share

Find help to solve issues with creating, uploading, and sharing files and folders in Dropbox. Get support and advice from the Dropbox Community.

Need more support

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!