No internet connection
  1. Home
  2. How to

Downloading files from a URL using the sf.net.httpRequest method

By Mitch Willard @Mitch_Willard
    2024-03-27 00:34:49.327Z

    I'm probably missing something here,

    But is there anyway to use the sf.net.httpRequest to download files?

    I can get all the information I need, just no way to download unless I go straight to a browser to download using the sf.file.open which works great until it's a Vision file which takes the browser wants to load before you can download it.

    Not sure that this is in the right direction

    sf.net.httpRequest({
        url: url,
        method: 'GET',
        headers: {
            'Authorization': `KeyCode`,
        },
        contentType: "UrlEncoded",
    });
    
    Solved in post #2, click to view
    • 10 replies
    1. Currently, sf.net.httpRequest is not suitable to download binary data or large files. It's designed for operating on text-based data that needs to be parsed by a script (for example, for integrating with REST API's).

      What's the use case for what you need to download?

      Note, if you know how to use curl on the command line (Terminal), you can also do stuff like in this post:

      ReplySolution
      1. I think this is a good excuse for us to look into adding a httpDownload action. Would probably make sense for a lot of workloads.

        1. Mitch Willard @Mitch_Willard
            2024-03-27 04:14:48.762Z2024-04-01 01:22:35.278Z

            a httpDownload action would be amazing!

            The case we'd like to use it for is with a ticketing system we use where we have all the information about a project to be mixed, where the producers/clients can also attach their files we need to do the project.
            Currently we have Soundflow doing all sorts of things using the REST API, where we can GET, POST, etc information to update if a project is for example being started or done.

            I was hoping we could access the files to speed up the workflow, particularly a script I wrote that imports all selected files with the information given by the users.

            in short, I want to be able to download directly from the ticket more efficiently.

            I'll look into curl cheers @chrscheuer

            1. Wow - nice use case indeed! Love this :)

              Hopefully, going via curl can get you unlocked for now, but I see no reason for us not to add proper httpDownload support.

              1. Mitch Willard @Mitch_Willard
                  2024-03-27 05:19:10.275Z

                  yeah it's amazing how much Soundflow helps with this work flow, it creates/opens sessions based of the name or session file path inside of the ticket, get's producers emails to send updates, even marking the tickets status off when we finish bouncing mixes which is all automated with one soundflow button. Saves us hours a day.

            2. In reply tochrscheuer:
              Mitch Willard @Mitch_Willard
                2024-03-27 04:48:39.726Z

                maybe I'm messing this up but is this the curl command to be able to download a file via a URL?

                sf.system.exec({
                    commandLine: `curl -O myURLHere`,
                });
                

                with the -O retaining the original name of the file?

                or should this be the command?

                sf.system.exec({
                    commandLine: `curl myURLHere -o fileName`,
                });
                
                1. The 2nd option here I think should be the one yes. You can experiment in Terminal to get the right one going, and once you have it nailed down, move it into a SF script and you should be good to go.

                  1. Mitch Willard @Mitch_Willard
                      2024-03-27 05:19:51.107Z

                      awesome will give it a go in Terminal and transfer it once I get it right.

                      1. In reply tochrscheuer:
                        Mitch Willard @Mitch_Willard
                          2024-03-27 07:22:11.953Z

                          Got it working @chrscheuer
                          You’re the man!
                          Thanks for all the help.

                    • S
                      In reply toMitch_Willard:
                      SoundFlow Bot @soundflowbot
                        2024-03-27 03:47:47.983Z

                        This issue is now tracked internally by SoundFlow as SF-1164