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

[IOS] Error saving to disk: "Could not write file: You don't have permission to save the file..." #46

Closed
victorbadila opened this issue Nov 29, 2017 · 6 comments

Comments

@victorbadila
Copy link

Hi, I'm trying to use ImageCrop with local file saving options:

<ImageCrop
  ref={(c) => { this.cropper = c; }}
  zoom={this.state.zoom}
  image={this.props.image}
  cropHeight={this.props.height}
  cropWidth={this.props.width}
  panToMove
  format="file"
  filePath="abc.jpg"
  pinchToZoom
/>

When I invoke this.cropper.crop() the returned Promise gets rejected "Could not write file: You don't have permission to save the file "abc.jpg"."
I presume it has something to do with declared permissions in Info.plist but I couldn't find anything related on the web. If there is a simple answer to this it would be worth adding it to the README documentation.

Somewhat related to the following: #39

@st0ffern
Copy link
Owner

This should be adressed in gl-react-native if you have any problems..
It is the permissions you struggle with..

@danmatthews
Copy link

danmatthews commented Jan 17, 2018

Hi - can you point me in the right direction of where to look so i can enable the right permissions to make this work?

Currently trying using the following props/config and i'm getting a similar error, but i cannot find anything on how to fix it.

<ImageCrop format={'file'} filePath={'avatar.jpg'} ref={"cropper"} image={this.state.image.uri} cropHeight={third} cropWidth={third} zoom={0} maxZoom={80} minZoom={0} panToMove={true} />

@st0ffern
Copy link
Owner

what i said ^^

@danmatthews
Copy link

Hey @Stoffern - i've looked all through the gl-react-native repo and couldn't see anything about how to address it.

I assume it's this repo, yes? https://github.com/gre/gl-react-native-v2

Anything you could point me to would be helpful - i realise it's not in the scope of your repo, but it
may be a common issue that i can contribute back to the readme once i've overcame it.

@st0ffern
Copy link
Owner

https://github.com/gre/gl-react-v2/blob/master/docs/api/Surface.md

in gl-react-native, format: "file" allows to save to a file. You also need to provide a filePath String (you should use react-native-fs to knows directory paths). The promise result will be a file://... url that you can use in

So you use react-native-fs to provide correct paths?

@danmatthews
Copy link

I don't, I use Expo's filesystem API, as i'm using Expo (detached to Expokit) - they produce filesystem URLs that seem to match the ones in the react-native-fs package, but i'll try and install react-native-fs and see if it solves my problem.

If it works, is it okay to submit a PR to the README to provide more information? It might help a few people out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants