Support http.getFile for URLs with query params

This commit is contained in:
vakrilov
2017-05-30 14:55:15 +03:00
parent 9551418b15
commit 3fe2815ded
5 changed files with 43 additions and 24 deletions

View File

@@ -4,6 +4,7 @@
import * as imageSourceModule from "../../image-source";
import * as platformModule from "../../platform";
import * as fsModule from "../../file-system";
import { getFilenameFromUrl } from "./http-request-common";
// this is imported for definition purposes only
import * as http from "../../http";
@@ -119,11 +120,11 @@ function onRequestComplete(requestId: number, result: org.nativescript.widgets.A
}
});
},
toFile: (destinationFilePath?: string) => {
var fs: typeof fsModule = require("file-system");
var fileName = callbacks.url;
toFile: (destinationFilePath: string) => {
var fs: typeof fsModule = require("file-system");
if (!destinationFilePath) {
destinationFilePath = fs.path.join(fs.knownFolders.documents().path, fileName.substring(fileName.lastIndexOf('/') + 1));
destinationFilePath = getFilenameFromUrl(callbacks.url);
}
var stream: java.io.FileOutputStream;
try {