FileError {code: 1, message: "NOT_FOUND_ERR"}

Hello! I have a problem when I try to use File Pluging’s moveFile method, I get this error.
FileError {code: 1, message: “NOT_FOUND_ERR”}
The strange thing is that the emulator works fine, but when I use it on the real device it doesn’t work. Please, I need someone to help me. I’ve been with this problem for two days. Thank you.

I share my code.

After taking a photo, I make it go through the renameFile method.

 getVideoFromCamera() {
        const videoUrlBehaviorSubject: BehaviorSubject<string> = new BehaviorSubject<string>('');

        this.mediaCapture.captureVideo({ limit: 1, duration: 60, quality: 0.5 })
            .then((data: MediaFile[]) => {
                const newFileNamePrefix = 'video-' + this.authProvider.getLoggedUserId();

                this.fileService.renameFile(data[0].fullPath, newFileNamePrefix)
                    .then((entry) => {
                        let videoUrl = entry.nativeURL;
                        if ('ios')) {
                            videoUrl = videoUrl.replace(/^file:\/\//, '');
                    .catch((err) => {

            }).catch((err: CaptureError) => {
                if (err.code !== '3') {

        return videoUrlBehaviorSubject.asObservable();
public async renameFile(fileName: string, newFileNamePrefix: string): Promise<Entry> {
        let filePath = fileName.substr(0, fileName.lastIndexOf('/') + 1);
        if ('ios') && !filePath.startsWith('file://')) {
            filePath = 'file://' + filePath;

        const oldFileName = fileName.substring(fileName.lastIndexOf('/') + 1);
        const newFileName: string = this.getUserFileName(fileName, newFileNamePrefix);

        return this.file.moveFile(filePath, oldFileName, filePath, newFileName);

When the this.file.moveFile method is executed it throws the error.

I get very nervous when I see code that manipulates either (a) dates or (b) URLs as strings. I try to do my best to treat both of those things like black boxes, only to be passed around to dedicated libraries whose job it is to manage them.

So is there any way you can rewrite this code without any of the munging around with the guts of URLs? (Bonus points for also getting rid of stuff intended only to execute on iOS). That just seems like a huge maintenance nightmare, and eliminating it may expose the proximate problem as well.

Thanks for answering, the code is not mine, I am migrated from ionic 3 to 5. In the end I did a refactoring of that and I was able to solve it. Thank you very much.