Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions www/FileTransfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ const FileTransfer = function () {
this.onprogress = null; // optional callback
};

const iOSPathFix = function (path) {
if (window.CDV_ASSETS_URL) {
const pathstart = window.CDV_ASSETS_URL + '/_app_file_';
if (path.startsWith(pathstart)) {
return 'file://' + path.substring(pathstart.length);
}
}
return path;
};

/**
* Given an absolute file path, uploads a file on the device to a remote server
* using a multipart HTTP request.
Expand All @@ -87,6 +97,9 @@ const FileTransfer = function () {
*/
FileTransfer.prototype.upload = function (filePath, server, successCallback, errorCallback, options, trustAllHosts) {
argscheck.checkArgs('ssFFO*', 'FileTransfer.upload', arguments);

filePath = iOSPathFix(filePath);

// check for options
let fileKey = null;
let fileName = null;
Expand Down Expand Up @@ -172,6 +185,8 @@ FileTransfer.prototype.download = function (source, target, successCallback, err
argscheck.checkArgs('ssFF*', 'FileTransfer.download', arguments);
const self = this;

target = iOSPathFix(target);

const basicAuthHeader = getBasicAuthHeader(source);
if (basicAuthHeader) {
source = source.replace(getUrlCredentials(source) + '@', '');
Expand Down
Loading