Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 71531

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

$
0
0

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 (this.platform.is('ios')) {
                            videoUrl = videoUrl.replace(/^file:\/\//, '');
                        }
                        videoUrlBehaviorSubject.next(videoUrl);
                    })
                    .catch((err) => {
                        videoUrlBehaviorSubject.error(err);

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

        return videoUrlBehaviorSubject.asObservable();
    }
public async renameFile(fileName: string, newFileNamePrefix: string): Promise<Entry> {
        let filePath = fileName.substr(0, fileName.lastIndexOf('/') + 1);
        if (this.platform.is('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.

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 71531

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>