NIK February 2016

How to move/copy a file from one one location to the other using phonegap

I am using the Phonegap File API but am having trouble copying a file from one location to the other.

  • my targeted device is iOS(ipad)

  • my iOS version is 9.2.1

  • I am working on windows platform

  • I am using phonegap build

my requirement :

I am capturing a video and its getting saved in some temp folder by default here is the location where its getting saved (/private/var/mobile/Containers/Data/Application/2183897E-3660-4145-A822-76F5B763E48D/tmp/capture-T0x17e7cae0.tmp.avqBi2/capturedvideo.MOV)

So I just want to move this (capturedvideo.MOV) video to photo album location in my ipad

This is my code which i am trying to make it work.

function success(entry) {
console.log("New Path: " + entry.fullPath);
}

function fail(error) {
alert(error.code);

}

function moveDir(entry) {
var parent = document.getElementById('parent').value,
    parentName = parent.substring(parent.lastIndexOf('/')+1),
    newName = document.getElementById('newName').value,
    parentEntry = new DirectoryEntry(parentName, parent);

// move the directory to a new directory and rename it
entry.moveTo(saveToPhotoAlbum, newName, success, fail);

}

Any help or working examples would be great.

Thanks

Nik`

Answers


puchmu February 2016

This is simply not possible on iOS, because Apple does not allow to move videos, images or any other files out of the app sandbox to other folders. The reason that the standard-camera on the iPad/iPhone is able to place pictures there is simply because this is a built-in feature that has special permissions which your third-party app will not be able to get.
This is of course only true as long as the device is not jailbroken.
For more infos, especially concerning the file-system layout and what you are allowed to store, you should take a look at the cordova-file-plugin Readme on Github:
https://github.com/apache/cordova-plugin-file

Post Status

Asked in February 2016
Viewed 1,006 times
Voted 9
Answered 1 times

Search




Leave an answer