React-native-fs: Is there any way of changing the default DocumentDirectoryPath to a path of our preference?

Created on 23 Jan 2018  路  6Comments  路  Source: itinance/react-native-fs

question

Most helpful comment

If i understand you correctly there is no need to use your own absolute paths to access the applications folder. You should use these constants as their purpose is exactly that what you want to achieve: https://github.com/itinance/react-native-fs#constants

You would then write something like

await RNFS.mkdir( RNFS.DocumentDirectoryPath + '/my-fancy-directory)

i guess you are working on android right?

All 6 comments

The DocumentDirectoryPath is based on Operating Systems defaults: (getPathForDirectory:NSDocumentDirectory) for iOS and the base application path for androids application context.

So the short answer is: no. But you are free to store your data at any other path if you want to do that (and if you are allowed to having write access). Just place an absolute path like "/my/absolute/path" to downloadFile or writeFile.

But to repeat it once more: there are specific restrictions on every OS and it depends on the systems permissions

@itinance would you mind showing me an example? cause im really not familiar with this

@itinance actually i want to create a file to a directory of my application's assets folder in android so how can I set the absolute path?(myprojectname/android/src/main/assets this is where i want the file to be created)

If i understand you correctly there is no need to use your own absolute paths to access the applications folder. You should use these constants as their purpose is exactly that what you want to achieve: https://github.com/itinance/react-native-fs#constants

You would then write something like

await RNFS.mkdir( RNFS.DocumentDirectoryPath + '/my-fancy-directory)

i guess you are working on android right?

@itinance yes im working on android
yeah i think , await RNFS.mkdir( RNFS.DocumentDirectoryPath + '/my-fancy-directory) this would work
thanks and if you don't mind, will get back if there is anything not working

Hey @CoderHar I'm trying to setup react-native-fs in my project but during build time, it fails with a certain error which I posted as #430. I've linked the library too. Do you happen to know if android api-25 is needed for this library to work. Also if you don't mind, could you share your project's package.json and system config. Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zaheerahmad92001 picture zaheerahmad92001  路  3Comments

wmonecke picture wmonecke  路  3Comments

onzag picture onzag  路  3Comments

crobinson42 picture crobinson42  路  4Comments

barnir picture barnir  路  3Comments