Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Error: "Parent folder doesn't exist" when using FileSystem #2667

Closed
1 of 4 tasks
quique24 opened this issue Mar 31, 2020 · 11 comments · Fixed by #2670
Closed
1 of 4 tasks

bug: Error: "Parent folder doesn't exist" when using FileSystem #2667

quique24 opened this issue Mar 31, 2020 · 11 comments · Fixed by #2670

Comments

@quique24
Copy link

quique24 commented Mar 31, 2020

Bug Report

Capacitor Version

npx cap doctor output:

💊 Capacitor Doctor 💊

Latest Dependencies:

@capacitor/cli: 1.5.2

@capacitor/core: 1.5.2

@capacitor/android: 1.5.2

@capacitor/ios: 1.5.2

Installed Dependencies:

@capacitor/cli 1.4.0

@capacitor/core 1.4.0

@capacitor/android 1.4.0

@capacitor/ios 2.0.0-beta.1

Affected Platform(s)

  • Android
  • iOS
  • Electron
  • Web

Current Behavior

When using FileSystem writeFile() gets an error "Parent folder doesn't exist"
My code was working perfectly till I update xcode

I am testing on IOS this happens in the phone as in the simulator from xcode

Expected Behavior

The file should be written with the path of the image

Sample Code or Sample Application Repo

async convertImage(imageUri) {
const { Camera, Filesystem } = Plugins;

const photoInTempStorage = await Filesystem.readFile({ path: imageUri });

const date = new Date(),
  time = date.getTime(),
  fileName = time + '.jpeg';

await Filesystem.writeFile({
  data: photoInTempStorage.data,
  path: fileName,
  directory: FilesystemDirectory.Data
});

const finalPhotoUri = await Filesystem.getUri({
  directory: FilesystemDirectory.Data,
  path: fileName
});

const photoPath = Capacitor.convertFileSrc(finalPhotoUri.uri);
// this.photo = this.domSanitizer.bypassSecurityTrustResourceUrl(photoPath);
this.images.push(photoPath);

}

deleteImage(imgEntry, position) {
this.images.splice(position, 1);
}

Reproduction Steps

I am testing on IOS this happens in the phone as in the simulator from xcode

With the capacitor camera I get the original photo path and the I send it to the convertImage(). Works fine until the writeFile() returns the "Parent folder doesn't exist" error

Other Technical Details

npm --version output: 6.9.0

node --version output: 10.16.0

pod --version output (iOS issues only): 1.9.1

Other Information

I am testing on IOS this happens in the phone as in the simulator from xcode

@quique24 quique24 changed the title bug: bug: Error: "Parent folder doesn't exist" when using FileSystem Mar 31, 2020
@jcesarmobile
Copy link
Member

Can you provide a sample app?

@jcesarmobile jcesarmobile added the needs reply needs reply from the user label Mar 31, 2020
@NullOfNull
Copy link

NullOfNull commented Mar 31, 2020

I created an app with official demo "my-first-app"(example application that builds a camera with gallery)
and this error happens
image
image

@cmaas
Copy link

cmaas commented Mar 31, 2020

Can confirm this, writing a file doesn't work for me either under iOS 13.4. Same error message.

@jcesarmobile
Copy link
Member

People, when I ask for a sample app is not because I don't believe, it's to reproduce and fix it faster, so comments confirming don't help.

@quique24
Copy link
Author

Can you provide a sample app?

https://github.com/quique24/file-demo

Here it is the demo app. It works fine with the created project but to reproduce the error is specifically in @capacitor/ios 2.0.0-beta.1

I run:
npm install @capacitor/ios@next
ionic cap update
And then its stops working returning de error

@jcesarmobile
Copy link
Member

Thanks for the sample project, but the issue is already fixed, will be available on next release

@HitenChawda46
Copy link

Thanks for the sample project, but the issue is already fixed, will be available on next release

Thanks for the sample project, but the issue is already fixed, will be available on next release

i am having these versions
@capacitor/cli 2.4.0
@capacitor/android 2.4.0
@capacitor/core 2.4.0
still getting same error on android

@frederikbosch
Copy link

And it looks to me that writing in subfolders is now broken.

@luckyboykg
Copy link

I solve this issue by add this parameter: recursive: true

Filesystem will auto add any missing parent folders for us.

await this.Filesystem.writeFile({
                        path: 'my-folder/image.png',
                        data: base64data.toString(),
                        directory: FilesystemDirectory.Documents,
                        recursive: true
                    });

@razmans
Copy link

razmans commented Oct 31, 2022

recursive: true

This works. Really appreciate this, thanks

@ionitron-bot
Copy link

ionitron-bot bot commented Nov 30, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Nov 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants