remobile / react-native-file-transfer

A file-transfer for react-native, code come from cordova, support for android and ios
MIT License
85 stars 22 forks source link

Cannot read property 'download' of undefined #6

Open XinYiWorld opened 8 years ago

XinYiWorld commented 8 years ago

when execute the mehtod exec(win, fail, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode, headers, this._id, httpMethod]); in download,the error happens.

UpCoder commented 7 years ago

Do you solve the problem? I also meet the problem. I find the function define in source code as follow:

FileTransfer.prototype.download = function(source, target, successCallback, errorCallback, trustAllHosts, options) {
    argscheck.checkArgs('ssFF*', 'FileTransfer.download', arguments);
    var self = this;
    var subscription;

    var basicAuthHeader = getBasicAuthHeader(source);
    if (basicAuthHeader) {
        source = source.replace(getUrlCredentials(source) + '@', '');

        options = options || {};
        options.headers = options.headers || {};
        options.headers[basicAuthHeader.name] = basicAuthHeader.value;
    }

    var headers = null;
    if (options) {
        headers = options.headers || null;
    }

    if (false && headers) {
        headers = convertHeadersToArray(headers);
    }

    var win = successCallback && function(result) {
        subscription && subscription.remove();
        successCallback(result);
    };

    var fail = errorCallback && function(e) {
        subscription && subscription.remove();
        var error = new FileTransferError(e.code, e.source, e.target, e.http_status, e.body, e.exception);
        errorCallback(error);
    };

    if (this.onprogress) {
        subscription = EventEmitter.addListener('DownloadProgress-' + this._id, function(result){
            self.onprogress(newProgressEvent(result));
        });
    }

    exec(win, fail, 'FileTransfer', 'download', [source, target, trustAllHosts, this._id, headers]);
};
Abdul-majid-ashrafi commented 7 years ago

@XinYiWorld Are you solved this issue.?