Skip to content

http.getFile(url) should strip query string from saved file name #3957

Closed

Description

@PeterStaev

I'm trying to download files that have some long query string parameters and I'm using http.getFile w/o specifying a local file name. The default file name that is picked by the framework includes both the file name and the query string and thus the save fails.

Expected:
The default file name that is generated should strip out any query string from the URL and just save with a file name that matches the url.

Activity

  1. tsonevn commented on Apr 7, 2017

    @tsonevn
    Contributor

    Hi @PeterStaev,
    Could you provide some more info about your case and the need of such a functionality?
    It would also help if you could provide some info about the use-cases, when this will improve the functionality of the getFile method.

    In that point, if you want to separate some parts of the URL you could simply use JavaScript split method.
    For example:

    var test = "https://httpbin.org/image?sample=test";
        var splstring = test.split("?");
        console.log(splstring[0]);
    
  2. PeterStaev commented on Apr 7, 2017

    @PeterStaev
    ContributorAuthor

    In the specific case I'm using this is i'm downloading files from AWS. Those files are in the following format:
    https://d3a8fsy4z5uwny.cloudfront.net/Thumbnails/1122a4b1-e9a2-463c-838e-c6d8dfc89f35.jpg?Expires=1491627540&Signature=kZ83lzc669Xg8jq-xMYPGx7....&Key-Pair-Id=APKAI7LA3QA3MJYCSYFQ

    Since I really don't need a specific file locally as I just need it downloaded locally so I can email the file, i decided to use the call http.getFile(url) (w/o specifying a file path). This tries to save the file as ....../1122a4b1-e9a2-463c-838e-c6d8dfc89f35.jpg?Expires=1491627540&Signature=kZ83lzc669Xg8jq-xMYPGx7....&Key-Pair-Id=APKAI7LA3QA3MJYCSYFQ and this fails.

    I've workaround this by specifing some temp local file name for the save, but I think the method that accepts only URL should not fail to save from URL that has a query string.

  3. tsonevn commented on Apr 7, 2017

    @tsonevn
    Contributor

    Hi @PeterStaev,
    Thank you for the detailed information.
    Indeed this is a valid scenario when you would like to downloaded file from URL with query string.
    We will research, what are the possible ways to implement this functionality for the getFile method.

    Regarding the topic, you could always create pull request, which extends the needed functionality for the method.

  4. added a commit that references this issue on Apr 15, 2017
    6ac4bf8
  5. added 2 commits that reference this issue on May 26, 2017
    bde9867
    8fcf4b1
  6. added
    ready for testTSC needs to test this and confirm against live production apps and automated test suites
    on May 30, 2017
  7. added this to the 3.1 milestone on May 30, 2017
  8. SvetoslavTsenov commented on Jun 9, 2017

    @SvetoslavTsenov
    Contributor

    The fix is already available in tns-core-modules@next and will be included in tns-core-modules@3.1.0

  9. added and removed
    ready for testTSC needs to test this and confirm against live production apps and automated test suites
    on Jun 20, 2017
  10. removed their assignment
    on Jun 20, 2017
  11. lock commented on Aug 28, 2019

    @lock

    This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  12. locked and limited conversation to collaborators on Aug 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions