Forum
    • Categories
    • Register
    • Login

    Server.downloadFile with signed Amazon S3 URL

    Scheduled Pinned Locked Moved General Questions
    16 Posts 3 Posters 458 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • David HealeyD
      David Healey @bendurso
      last edited by

      @bendurso I'm guessing that link doesn't go directly to a file but redirects and maybe that is causing the issue.

      Free HISE Bootcamp Full Course for beginners.
      YouTube Channel - Public HISE tutorials
      My Patreon - HISE tutorials

      bendursoB 1 Reply Last reply Reply Quote 0
      • bendursoB
        bendurso @David Healey
        last edited by bendurso

        @d-healey The link is the final one. But your comment led me to think the link was different, so I checked it and realized that the download link in Chrome transforms the " into %22 and the spaces into %20.

        I can replace the spaces. But how do I transform the " into %22?
        Because this doesnt work

        String.replace(""", "%22");
        

        update: ohh, like this:

        
        String.replace("\"", "%22");
        

        Now the link is identical.. but still doesnt work :(

        bendursoB 1 Reply Last reply Reply Quote 0
        • bendursoB
          bendurso @bendurso
          last edited by

          @bendurso The link contains 1359 characters. Maybe that could be the issue? Is there max limit for the link length?

          David HealeyD 1 Reply Last reply Reply Quote 0
          • David HealeyD
            David Healey @bendurso
            last edited by

            @bendurso said in Server.downloadFile with signed Amazon S3 URL:

            The link contains 1359 characters. Maybe that could be the issue? Is there max limit for the link length?

            Could be, I'm not sure. I believe HISE is using cURL to do the download so you can test that by running it manually in a terminal.

            Free HISE Bootcamp Full Course for beginners.
            YouTube Channel - Public HISE tutorials
            My Patreon - HISE tutorials

            bendursoB 1 Reply Last reply Reply Quote 1
            • bendursoB
              bendurso @David Healey
              last edited by

              @d-healey Thanks, yes it works with curl in terminal.

              In HISE, I'm clearing the HttpHeader before starting the download, as I read in the forum, and I'm making sure not to repeat the base URL (just using https://).

              It works with links from other servers, but it doesn’t seem to work with signed S3 URLs.

              David HealeyD 1 Reply Last reply Reply Quote 0
              • David HealeyD
                David Healey @bendurso
                last edited by

                @bendurso Does it work in a private browser session?

                Free HISE Bootcamp Full Course for beginners.
                YouTube Channel - Public HISE tutorials
                My Patreon - HISE tutorials

                bendursoB 1 Reply Last reply Reply Quote 0
                • bendursoB
                  bendurso @David Healey
                  last edited by

                  @d-healey yeap :)

                  David HealeyD 1 Reply Last reply Reply Quote 0
                  • David HealeyD
                    David Healey @bendurso
                    last edited by

                    @bendurso I'm stumped then... You could use cURL directly from in HISE by calling it as a process - @aaronventure posted about this a while back I think.

                    Free HISE Bootcamp Full Course for beginners.
                    YouTube Channel - Public HISE tutorials
                    My Patreon - HISE tutorials

                    bendursoB 1 Reply Last reply Reply Quote 1
                    • bendursoB
                      bendurso @David Healey
                      last edited by

                      @David-Healey Thanks. It worked with cURL as a background process. I read that if the user has a Windows version prior to 2019 wont work. Should I use powershell for Windows for better compatibility right?

                      David HealeyD 1 Reply Last reply Reply Quote 0
                      • David HealeyD
                        David Healey @bendurso
                        last edited by

                        @bendurso said in Server.downloadFile with signed Amazon S3 URL:

                        Thanks. It worked with cURL as a background process.

                        I'd really like to know why it doesn't work with the standard downloadFile call.

                        @bendurso said in Server.downloadFile with signed Amazon S3 URL:

                        Should I use powershell for Windows for better compatibility right?

                        I don't know, I think powershell needs permissions doesn't it?

                        Free HISE Bootcamp Full Course for beginners.
                        YouTube Channel - Public HISE tutorials
                        My Patreon - HISE tutorials

                        bendursoB 1 Reply Last reply Reply Quote 0
                        • bendursoB
                          bendurso @David Healey
                          last edited by bendurso

                          @David-Healey I found a post where Dan was using the same amazon s3 links as me.
                          https://forum.hise.audio/topic/4635/question-about-queued-downloads-from-amazon-s3/26

                          I'm actually trying to use moonbase, but I got the same links for download.

                          @Dan-Korneff How did you solve this?

                          Dan KorneffD 1 Reply Last reply Reply Quote 0
                          • Dan KorneffD
                            Dan Korneff @bendurso
                            last edited by

                            @bendurso I can't quite remember. Reading the post it seems to be related to how my webserver was redirecting the traffic. I'll take a look in the AM to see where I left off

                            Dan Korneff - Producer / Mixer / Audio Nerd

                            1 Reply Last reply Reply Quote 0
                            • bendursoB
                              bendurso
                              last edited by

                              @David-Healey @Dan-Korneff Great news! I was able to fix the issue with Amazon S3 pre-signed URLs and the HISE Server.downloadFile function.

                              Thanks to Dan's explanation of the source code (on the other post), the problem was identified:

                              HISE original logic sees the ? in the S3 URL and assumes it needs to separate and re-parse the query string into a separate parameter object. This process destroys the specific encoding required for the X-Amz-Signature, invalidating the S3 link.

                              So, I modified the ScriptingApi::Server::downloadFile function in the HISE source code to skip the parameter parsing if the URL contains the S3-specific parameter "X-Amz-Algorithm=".

                              I think this should be changed in the HISE source code because AWS S3 are pretty common.

                              David HealeyD 1 Reply Last reply Reply Quote 2
                              • David HealeyD
                                David Healey @bendurso
                                last edited by David Healey

                                @bendurso said in Server.downloadFile with signed Amazon S3 URL:

                                I think this should be changed in the HISE source code because AWS S3 are pretty common.

                                Is parameter splitting ever needed with a file download? Shouldn't we leave that up to the scripter to pass parameters via the parameter argument of the downloadFile function?

                                We could add a convenience function that converts a URL query string to a parameters object.

                                Free HISE Bootcamp Full Course for beginners.
                                YouTube Channel - Public HISE tutorials
                                My Patreon - HISE tutorials

                                bendursoB 1 Reply Last reply Reply Quote 1
                                • bendursoB
                                  bendurso @David Healey
                                  last edited by

                                  @David-Healey Haha that make sense too :)

                                  1 Reply Last reply Reply Quote 0
                                  • First post
                                    Last post

                                  21

                                  Online

                                  2.1k

                                  Users

                                  13.1k

                                  Topics

                                  113.6k

                                  Posts