Ionic Native File TypeError

I am using the cordova File plugin to store a picture on the device and then use file transfer to upload it to a remote location. Currently I am trying to store the picture and I run into a TypeError. My code is as shown below. What could be causing this error?

  private copyFileToLocalDir(namePath, currentName, newFileName) {
    this.file.copyFile(namePath, currentName, cordova.file.dataDirectory, newFileName)
      .then(success => {
        this.lastImage = newFileName;
      }, error => {

It’d be nice to know the error message.

However, my guess is that it’s complaining about cordova.file.dataDirectory
Instead of that you should use: this.file.dataDirectory

I switched it to this.file.dataDirectory and I still get the type error. The error message it throws is just TypeError.

Do I need to define the response types? If so, what are they?

All the error message says is “TypeError”?

Is this a compile-time error? A run-time error?

What line is it throwing the error?

I am running the app on an iPhone 7 plus. I take the picture on the phone, confirm the picture, then I execute the copyFileToLocalDir function. I get the error once the copyFileToLocalDir function is executed. It presents the toast (from this.presentToast(error);) and all it says is TypeError.

What does the safari inspector show if you hook it up?

I actually decided against storing the picture and uploading it as a reference. Instead i’m saving the URL from the temp storage in a variable and using it to upload the picture. Thanks for your help, @SigmundFroyd, though!

I was about to answer that to you, because it saves a lot of hassle. My app uses firebase file storage.

Have fun with ionic :):grinning: