mirror of
https://github.com/status-im/react-native-fs.git
synced 2025-02-28 23:10:29 +00:00
connected ExternalDirectoryPath constant to getExternalFilesDir (null for iOS)
This commit is contained in:
parent
8c9e28ff3d
commit
a063f23ed9
@ -189,6 +189,7 @@ var RNFS = {
|
||||
MainBundlePath: RNFSManager.MainBundlePath,
|
||||
CachesDirectoryPath: RNFSManager.NSCachesDirectoryPath,
|
||||
DocumentDirectoryPath: RNFSManager.NSDocumentDirectoryPath,
|
||||
ExternalDirectoryPath: RNFSManager.NSExternalDirectoryPath,
|
||||
LibraryDirectoryPath: RNFSManager.NSLibraryDirectoryPath,
|
||||
PicturesDirectoryPath: RNFSManager.NSPicturesDirectoryPath
|
||||
};
|
||||
|
@ -63,7 +63,7 @@ function testWriteAndReadFile() {
|
||||
|
||||
|
||||
function testCreateAndDeleteFile() {
|
||||
var path = RNFS.DocumentDirectoryPath + '/test.txt';
|
||||
var path = RNFS.ExternalDirectoryPath + '/test.txt';
|
||||
var text = 'Lorem ipsum dolor sit amet';
|
||||
var readText;
|
||||
|
||||
|
@ -171,6 +171,7 @@ The following constants are available on the `RNFS` export:
|
||||
`MainBundlePath` (`String`) The absolute path to the main bundle directory
|
||||
`CachesDirectoryPath` (`String`) The absolute path to the caches directory
|
||||
`DocumentDirectoryPath` (`String`) The absolute path to the document directory
|
||||
`ExternalDirectoryPath` (`String`) The absolute path to the external, shared directory (android only)
|
||||
|
||||
### `promise readDir(path)`
|
||||
|
||||
|
@ -278,6 +278,7 @@ RCT_EXPORT_METHOD(pathForBundle:(NSString *)bundleNamed
|
||||
@"MainBundlePath": [[NSBundle mainBundle] bundlePath],
|
||||
@"NSCachesDirectoryPath": [self getPathForDirectory:NSCachesDirectory],
|
||||
@"NSDocumentDirectoryPath": [self getPathForDirectory:NSDocumentDirectory],
|
||||
@"NSExternalDirectoryPath": [NSNull null],
|
||||
@"NSLibraryDirectoryPath": [self getPathForDirectory:NSLibraryDirectory],
|
||||
@"NSFileTypeRegular": NSFileTypeRegular,
|
||||
@"NSFileTypeDirectory": NSFileTypeDirectory
|
||||
|
@ -38,6 +38,7 @@ import com.facebook.react.modules.core.DeviceEventManagerModule;
|
||||
public class RNFSManager extends ReactContextBaseJavaModule {
|
||||
|
||||
private static final String NSDocumentDirectoryPath = "NSDocumentDirectoryPath";
|
||||
private static final String NSExternalDirectoryPath = "NSExternalDirectoryPath";
|
||||
private static final String NSPicturesDirectoryPath = "NSPicturesDirectoryPath";
|
||||
private static final String NSCachesDirectoryPath = "NSCachesDirectoryPath";
|
||||
private static final String NSDocumentDirectory = "NSDocumentDirectory";
|
||||
@ -308,6 +309,12 @@ public class RNFSManager extends ReactContextBaseJavaModule {
|
||||
final Map<String, Object> constants = new HashMap<>();
|
||||
constants.put(NSDocumentDirectory, 0);
|
||||
constants.put(NSDocumentDirectoryPath, this.getReactApplicationContext().getFilesDir().getAbsolutePath());
|
||||
File externalDirectory = this.getReactApplicationContext().getExternalFilesDir(null);
|
||||
if (externalDirectory != null) {
|
||||
constants.put(NSExternalDirectoryPath, externalDirectory.getAbsolutePath());
|
||||
} else {
|
||||
constants.put(NSExternalDirectoryPath, null);
|
||||
}
|
||||
constants.put(NSPicturesDirectoryPath, Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getAbsolutePath());
|
||||
constants.put(NSCachesDirectoryPath, this.getReactApplicationContext().getCacheDir().getAbsolutePath());
|
||||
constants.put(NSFileTypeRegular, 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user