Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: $cordovaTransfer.upload is not a function #357

Closed
felipetoffolo1 opened this issue Jul 27, 2016 · 7 comments
Closed

Comments

@felipetoffolo1
Copy link

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;  
    });


  }`
@ihadeed
Copy link
Collaborator

ihadeed commented Jul 27, 2016

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(...);

@felipetoffolo1
Copy link
Author

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

@ihadeed
Copy link
Collaborator

ihadeed commented Jul 28, 2016

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

@mlynch
Copy link
Collaborator

mlynch commented Jul 29, 2016

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

@ihadeed
Copy link
Collaborator

ihadeed commented Aug 1, 2016

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

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

@raykin
Copy link

raykin commented Aug 4, 2016

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

@mlynch
Copy link
Collaborator

mlynch commented Aug 4, 2016

The constructor isn't getting carried over, fixing now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants