Ionic-native: Uncaught TypeError: $cordovaTransfer.upload is not a function

Created on 27 Jul 2016  路  7Comments  路  Source: ionic-team/ionic-native

HI,
i have a question.
I'm trying to use ionic native in my Ionic 1 project.
but when it try
$cordovaTransfer.upload()
i receive the errro
Uncaught TypeError: $cordovaTransfer.upload is not a function

here is my code

` cordovaUpload: function (file, objectType, fileName, chunkMode) {

    chunkMode | (chunkMode = false);

    var container = this.fileContainer(objectType);

    var options = {
      fileKey: "file",
      fileName: fileName,
      chunkedMode: chunkMode,
      mimeType: "image/jpg"
    };


    $cordovaTransfer.upload(file, CONFIG.urlApi + '/api/containers/' + container + '/upload',  options).then(function(data){
    return data;  
    });


  }`
bug ng1

Most helpful comment

Hey there,

This plugin (and a few others) is instance based. You need to do something like the following:

var transfer = new $cordovaTransfer();
transfer.upload(...);

All 7 comments

Hey there,

This plugin (and a few others) is instance based. You need to do something like the following:

var transfer = new $cordovaTransfer();
transfer.upload(...);

Hi @ihadeed thank you for the answer.
But i tried that one and got a error too
cordova.js:314 Uncaught TypeError: $cordovaTransfer is not a constructor

@mlynch can you have a look at this when you get a chance?

Ah, perhaps the instance based stuff isn't correctly abstracted for ng1...

@felipetoffolo1 can you try to use the plugin via the global variable IonicNative..
example:

var transfer = new IonicNative.Transfer();
transfer.upload(...)

@ihadeed tried your latest example, but doesn't work. No error in console, but nothing happened too

The constructor isn't getting carried over, fixing now

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ajcrites picture ajcrites  路  3Comments

FdezRomero picture FdezRomero  路  4Comments

mateo666 picture mateo666  路  3Comments

Manduro picture Manduro  路  3Comments

hobbydevs picture hobbydevs  路  3Comments