Skip to content Skip to sidebar Skip to footer

Cordova Move File Using The File Url

How can I move a file using the URL I get from the Camera? neither successCallback nor errorCallback is called by the function moveTo. Can anyone tell me what I am doing wrong and

Solution 1:

You're trying to call the function moveTo on a String.

moveTO is not a function of String but of fileEntry. So first thing you need to do is get a fileEntry from your URI.

For that you'll call window.resolveLocalFileSystemURL :

functionmoveFile(fileUri) {
    window.resolveLocalFileSystemURL(
          fileUri,
          function(fileEntry){
                newFileUri  = cordova.file.dataDirectory + "images/";
                oldFileUri  = fileUri;
                fileExt     = "." + oldFileUri.split('.').pop();

                newFileName = guid("car") + fileExt;
                window.resolveLocalFileSystemURL(newFileUri,
                        function(dirEntry) {
                            // move the file to a new directory and rename it
                            fileEntry.moveTo(dirEntry, newFileName, successCallback, errorCallback);
                        },
                        errorCallback);
          },
          errorCallback);
}

Post a Comment for "Cordova Move File Using The File Url"