You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
http.getFile(url) should strip query string from saved file name #3957
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.
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]);
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.
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.
Activity
tsonevn commentedon Apr 7, 2017
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
getFilemethod.In that point, if you want to separate some parts of the URL you could simply use JavaScript
splitmethod.For example:
PeterStaev commentedon Apr 7, 2017
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=APKAI7LA3QA3MJYCSYFQSince 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=APKAI7LA3QA3MJYCSYFQand 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.
tsonevn commentedon Apr 7, 2017
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
getFilemethod.Regarding the topic, you could always create pull request, which extends the needed functionality for the method.
Remove query params from target filename on getFile (fixes NativeScri…
Remove query params from target filename on getFile (fixes NativeScri…
Merge branch 'bugfix/NativeScript#3957' of https://github.com/vjoao/N…
SvetoslavTsenov commentedon Jun 9, 2017
The fix is already available in tns-core-modules@next and will be included in tns-core-modules@3.1.0
lock commentedon Aug 28, 2019
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.