react-native-blob-util 0.22.0 → 0.22.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/.eslintrc.js +56 -56
  2. package/LICENSE +21 -21
  3. package/Migration.md +41 -41
  4. package/NuGet.config +11 -11
  5. package/README.md +1109 -1104
  6. package/android/gradle.properties +1 -1
  7. package/android/src/main/AndroidManifest.xml +37 -37
  8. package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilConfig.java +57 -57
  9. package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilConst.java +20 -20
  10. package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilFileTransformer.java +9 -9
  11. package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilImpl.java +431 -431
  12. package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilProgressConfig.java +39 -39
  13. package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilReq.java +1014 -1014
  14. package/android/src/main/java/com/ReactNativeBlobUtil/Response/ReactNativeBlobUtilDefaultResp.java +98 -98
  15. package/android/src/main/java/com/ReactNativeBlobUtil/Response/ReactNativeBlobUtilFileResp.java +166 -166
  16. package/android/src/main/java/com/ReactNativeBlobUtil/Utils/FileDescription.java +19 -19
  17. package/android/src/main/java/com/ReactNativeBlobUtil/Utils/FileProvider.java +4 -4
  18. package/android/src/main/java/com/ReactNativeBlobUtil/Utils/MimeType.java +70 -70
  19. package/android/src/main/java/com/ReactNativeBlobUtil/Utils/PathResolver.java +223 -223
  20. package/android/src/main/java/com/ReactNativeBlobUtil/Utils/Tls12SocketFactory.java +68 -68
  21. package/android/src/main/res/values/strings.xml +3 -3
  22. package/android/src/main/res/xml/provider_paths.xml +12 -12
  23. package/android.js +58 -58
  24. package/class/ReactNativeBlobUtilCanceledFetchError.js +9 -9
  25. package/class/ReactNativeBlobUtilFile.js +5 -5
  26. package/class/ReactNativeBlobUtilReadStream.js +84 -84
  27. package/class/ReactNativeBlobUtilSession.js +68 -68
  28. package/class/ReactNativeBlobUtilWriteStream.js +50 -50
  29. package/class/StatefulPromise.js +7 -7
  30. package/codegenSpecs/NativeBlobUtils.js +86 -86
  31. package/components/Fetch.onPress.js +10 -10
  32. package/components/Fetch.when.js +15 -15
  33. package/fetch.js +350 -350
  34. package/fs.js +480 -480
  35. package/index.js +64 -64
  36. package/index.js.flow +192 -192
  37. package/index.web.js +1 -1
  38. package/ios/PrivacyInfo.xcprivacy +28 -28
  39. package/ios/ReactNativeBlobUtil/ReactNativeBlobUtil.h +55 -55
  40. package/ios/ReactNativeBlobUtil/ReactNativeBlobUtil.mm +992 -992
  41. package/ios/ReactNativeBlobUtil.xcodeproj/project.pbxproj +405 -405
  42. package/ios/ReactNativeBlobUtilConst.h +58 -58
  43. package/ios/ReactNativeBlobUtilConst.mm +47 -47
  44. package/ios/ReactNativeBlobUtilFS.h +108 -108
  45. package/ios/ReactNativeBlobUtilFS.mm +1064 -1064
  46. package/ios/ReactNativeBlobUtilFileTransformer.h +23 -23
  47. package/ios/ReactNativeBlobUtilFileTransformer.mm +20 -20
  48. package/ios/ReactNativeBlobUtilNetwork.h +49 -49
  49. package/ios/ReactNativeBlobUtilNetwork.mm +159 -159
  50. package/ios/ReactNativeBlobUtilProgress.h +32 -32
  51. package/ios/ReactNativeBlobUtilProgress.mm +57 -57
  52. package/ios/ReactNativeBlobUtilReqBuilder.h +37 -37
  53. package/ios/ReactNativeBlobUtilReqBuilder.mm +292 -292
  54. package/ios/ReactNativeBlobUtilRequest.h +48 -48
  55. package/ios/ReactNativeBlobUtilRequest.mm +584 -584
  56. package/ios.js +61 -61
  57. package/json-stream.js +42 -42
  58. package/lib/oboe-browser.js +2703 -2703
  59. package/mediacollection.js +36 -36
  60. package/package.json +68 -68
  61. package/polyfill/Blob.js +362 -362
  62. package/polyfill/Event.js +11 -11
  63. package/polyfill/EventTarget.js +78 -78
  64. package/polyfill/Fetch.js +219 -219
  65. package/polyfill/File.js +27 -27
  66. package/polyfill/FileReader.js +91 -91
  67. package/polyfill/ProgressEvent.js +32 -32
  68. package/polyfill/XMLHttpRequest.js +466 -466
  69. package/polyfill/XMLHttpRequestEventTarget.js +126 -126
  70. package/polyfill/index.js +11 -11
  71. package/react-native-blob-util.podspec +48 -48
  72. package/types.js +69 -69
  73. package/utils/log.js +40 -40
  74. package/utils/unicode.js +7 -7
  75. package/utils/uri.js +33 -33
  76. package/utils/uuid.js +4 -4
  77. package/windows/ExperimentalFeatures.props +33 -33
  78. package/windows/README.md +2 -2
  79. package/windows/ReactNativeBlobUtil/PropertySheet.props +15 -15
  80. package/windows/ReactNativeBlobUtil/ReactNativeBlobUtil.cpp +1836 -1836
  81. package/windows/ReactNativeBlobUtil/ReactNativeBlobUtil.def +3 -3
  82. package/windows/ReactNativeBlobUtil/ReactNativeBlobUtil.h +372 -372
  83. package/windows/ReactNativeBlobUtil/ReactNativeBlobUtil.vcxproj +139 -139
  84. package/windows/ReactNativeBlobUtil/ReactNativeBlobUtil.vcxproj.filters +43 -43
  85. package/windows/ReactNativeBlobUtil/ReactPackageProvider.cpp +20 -20
  86. package/windows/ReactNativeBlobUtil/ReactPackageProvider.h +24 -24
  87. package/windows/ReactNativeBlobUtil/ReactPackageProvider.idl +9 -9
  88. package/windows/ReactNativeBlobUtil/codegen/.clang-format +1 -1
  89. package/windows/ReactNativeBlobUtil/codegen/NativeBlobUtilsDataTypes.g.h +42 -42
  90. package/windows/ReactNativeBlobUtil/codegen/NativeBlobUtilsSpec.g.h +353 -353
  91. package/windows/ReactNativeBlobUtil/packages.config +3 -3
  92. package/windows/ReactNativeBlobUtil/packages.lock.json +59 -59
  93. package/windows/ReactNativeBlobUtil/pch.cpp +1 -1
  94. package/windows/ReactNativeBlobUtil/pch.h +30 -30
  95. package/windows/ReactNativeBlobUtil/resource.h +5 -5
  96. package/windows/ReactNativeBlobUtil/targetver.h +8 -8
  97. package/windows/ReactNativeBlobUtil.sln +43 -43
@@ -1,58 +1,58 @@
1
- //
2
- // ReactNativeBlobUtilConst.h
3
- // ReactNativeBlobUtil
4
- //
5
- // Created by Ben Hsieh on 2016/6/6.
6
- // Copyright © 2016年 suzuri04x2. All rights reserved.
7
- //
8
-
9
- #ifndef ReactNativeBlobUtilConst_h
10
- #define ReactNativeBlobUtilConst_h
11
-
12
- #import <Foundation/Foundation.h>
13
-
14
- // lib event
15
- extern NSString *const MSG_EVENT;
16
- extern NSString *const MSG_EVENT_LOG;
17
- extern NSString *const MSG_EVENT_WARN;
18
- extern NSString *const MSG_EVENT_ERROR;
19
-
20
- extern NSString *const EVENT_EXPIRE;
21
- extern NSString *const EVENT_PROGRESS;
22
- extern NSString *const EVENT_SERVER_PUSH;
23
- extern NSString *const EVENT_PROGRESS_UPLOAD;
24
- extern NSString *const EVENT_STATE_CHANGE;
25
- extern NSString *const EVENT_FILESYSTEM;
26
-
27
- extern NSString *const FILE_PREFIX;
28
- extern NSString *const ASSET_PREFIX;
29
- extern NSString *const AL_PREFIX;
30
-
31
- // config
32
- extern NSString *const CONFIG_USE_TEMP;
33
- extern NSString *const CONFIG_TRANSFORM_FILE;
34
- extern NSString *const CONFIG_FILE_PATH;
35
- extern NSString *const CONFIG_FILE_EXT;
36
- extern NSString *const CONFIG_TRUSTY;
37
- extern NSString *const CONFIG_WIFI_ONLY;
38
- extern NSString *const CONFIG_INDICATOR;
39
- extern NSString *const CONFIG_KEY;
40
- extern NSString *const CONFIG_EXTRA_BLOB_CTYPE;
41
-
42
- // fs events
43
- extern NSString *const FS_EVENT_DATA;
44
- extern NSString *const FS_EVENT_END;
45
- extern NSString *const FS_EVENT_WARN;
46
- extern NSString *const FS_EVENT_ERROR;
47
-
48
- extern NSString *const KEY_REPORT_PROGRESS;
49
- extern NSString *const KEY_REPORT_UPLOAD_PROGRESS;
50
-
51
- // response type
52
- extern NSString *const RESP_TYPE_BASE64;
53
- extern NSString *const RESP_TYPE_UTF8;
54
- extern NSString *const RESP_TYPE_PATH;
55
-
56
-
57
-
58
- #endif /* ReactNativeBlobUtilConst_h */
1
+ //
2
+ // ReactNativeBlobUtilConst.h
3
+ // ReactNativeBlobUtil
4
+ //
5
+ // Created by Ben Hsieh on 2016/6/6.
6
+ // Copyright © 2016年 suzuri04x2. All rights reserved.
7
+ //
8
+
9
+ #ifndef ReactNativeBlobUtilConst_h
10
+ #define ReactNativeBlobUtilConst_h
11
+
12
+ #import <Foundation/Foundation.h>
13
+
14
+ // lib event
15
+ extern NSString *const MSG_EVENT;
16
+ extern NSString *const MSG_EVENT_LOG;
17
+ extern NSString *const MSG_EVENT_WARN;
18
+ extern NSString *const MSG_EVENT_ERROR;
19
+
20
+ extern NSString *const EVENT_EXPIRE;
21
+ extern NSString *const EVENT_PROGRESS;
22
+ extern NSString *const EVENT_SERVER_PUSH;
23
+ extern NSString *const EVENT_PROGRESS_UPLOAD;
24
+ extern NSString *const EVENT_STATE_CHANGE;
25
+ extern NSString *const EVENT_FILESYSTEM;
26
+
27
+ extern NSString *const FILE_PREFIX;
28
+ extern NSString *const ASSET_PREFIX;
29
+ extern NSString *const AL_PREFIX;
30
+
31
+ // config
32
+ extern NSString *const CONFIG_USE_TEMP;
33
+ extern NSString *const CONFIG_TRANSFORM_FILE;
34
+ extern NSString *const CONFIG_FILE_PATH;
35
+ extern NSString *const CONFIG_FILE_EXT;
36
+ extern NSString *const CONFIG_TRUSTY;
37
+ extern NSString *const CONFIG_WIFI_ONLY;
38
+ extern NSString *const CONFIG_INDICATOR;
39
+ extern NSString *const CONFIG_KEY;
40
+ extern NSString *const CONFIG_EXTRA_BLOB_CTYPE;
41
+
42
+ // fs events
43
+ extern NSString *const FS_EVENT_DATA;
44
+ extern NSString *const FS_EVENT_END;
45
+ extern NSString *const FS_EVENT_WARN;
46
+ extern NSString *const FS_EVENT_ERROR;
47
+
48
+ extern NSString *const KEY_REPORT_PROGRESS;
49
+ extern NSString *const KEY_REPORT_UPLOAD_PROGRESS;
50
+
51
+ // response type
52
+ extern NSString *const RESP_TYPE_BASE64;
53
+ extern NSString *const RESP_TYPE_UTF8;
54
+ extern NSString *const RESP_TYPE_PATH;
55
+
56
+
57
+
58
+ #endif /* ReactNativeBlobUtilConst_h */
@@ -1,47 +1,47 @@
1
- //
2
- // ReactNativeBlobUtilConst.m
3
- // ReactNativeBlobUtil
4
- //
5
- // Created by Ben Hsieh on 2016/6/6.
6
- // Copyright © 2016 wkh237. All rights reserved.
7
- //
8
- #import "ReactNativeBlobUtilConst.h"
9
-
10
- NSString *const FILE_PREFIX = @"ReactNativeBlobUtil-file://";
11
- NSString *const ASSET_PREFIX = @"bundle-assets://";
12
- NSString *const AL_PREFIX = @"assets-library://";
13
-
14
- // fetch configs
15
- NSString *const CONFIG_USE_TEMP = @"fileCache";
16
- NSString *const CONFIG_TRANSFORM_FILE = @"transformFile";
17
- NSString *const CONFIG_FILE_PATH = @"path";
18
- NSString *const CONFIG_FILE_EXT = @"appendExt";
19
- NSString *const CONFIG_TRUSTY = @"trusty";
20
- NSString *const CONFIG_WIFI_ONLY = @"wifiOnly";
21
- NSString *const CONFIG_INDICATOR = @"indicator";
22
- NSString *const CONFIG_KEY = @"key";
23
- NSString *const CONFIG_EXTRA_BLOB_CTYPE = @"binaryContentTypes";
24
-
25
- NSString *const EVENT_STATE_CHANGE = @"ReactNativeBlobUtilState";
26
- NSString *const EVENT_SERVER_PUSH = @"ReactNativeBlobUtilServerPush";
27
- NSString *const EVENT_PROGRESS = @"ReactNativeBlobUtilProgress";
28
- NSString *const EVENT_PROGRESS_UPLOAD = @"ReactNativeBlobUtilProgress-upload";
29
- NSString *const EVENT_EXPIRE = @"ReactNativeBlobUtilExpire";
30
- NSString *const EVENT_FILESYSTEM = @"ReactNativeBlobUtilFilesystem";
31
-
32
- NSString *const MSG_EVENT = @"ReactNativeBlobUtilMessage";
33
- NSString *const MSG_EVENT_LOG = @"log";
34
- NSString *const MSG_EVENT_WARN = @"warn";
35
- NSString *const MSG_EVENT_ERROR = @"error";
36
- NSString *const FS_EVENT_DATA = @"data";
37
- NSString *const FS_EVENT_END = @"end";
38
- NSString *const FS_EVENT_WARN = @"warn";
39
- NSString *const FS_EVENT_ERROR = @"error";
40
-
41
- NSString *const KEY_REPORT_PROGRESS = @"reportProgress";
42
- NSString *const KEY_REPORT_UPLOAD_PROGRESS = @"reportUploadProgress";
43
-
44
- // response type
45
- NSString *const RESP_TYPE_BASE64 = @"base64";
46
- NSString *const RESP_TYPE_UTF8 = @"utf8";
47
- NSString *const RESP_TYPE_PATH = @"path";
1
+ //
2
+ // ReactNativeBlobUtilConst.m
3
+ // ReactNativeBlobUtil
4
+ //
5
+ // Created by Ben Hsieh on 2016/6/6.
6
+ // Copyright © 2016 wkh237. All rights reserved.
7
+ //
8
+ #import "ReactNativeBlobUtilConst.h"
9
+
10
+ NSString *const FILE_PREFIX = @"ReactNativeBlobUtil-file://";
11
+ NSString *const ASSET_PREFIX = @"bundle-assets://";
12
+ NSString *const AL_PREFIX = @"assets-library://";
13
+
14
+ // fetch configs
15
+ NSString *const CONFIG_USE_TEMP = @"fileCache";
16
+ NSString *const CONFIG_TRANSFORM_FILE = @"transformFile";
17
+ NSString *const CONFIG_FILE_PATH = @"path";
18
+ NSString *const CONFIG_FILE_EXT = @"appendExt";
19
+ NSString *const CONFIG_TRUSTY = @"trusty";
20
+ NSString *const CONFIG_WIFI_ONLY = @"wifiOnly";
21
+ NSString *const CONFIG_INDICATOR = @"indicator";
22
+ NSString *const CONFIG_KEY = @"key";
23
+ NSString *const CONFIG_EXTRA_BLOB_CTYPE = @"binaryContentTypes";
24
+
25
+ NSString *const EVENT_STATE_CHANGE = @"ReactNativeBlobUtilState";
26
+ NSString *const EVENT_SERVER_PUSH = @"ReactNativeBlobUtilServerPush";
27
+ NSString *const EVENT_PROGRESS = @"ReactNativeBlobUtilProgress";
28
+ NSString *const EVENT_PROGRESS_UPLOAD = @"ReactNativeBlobUtilProgress-upload";
29
+ NSString *const EVENT_EXPIRE = @"ReactNativeBlobUtilExpire";
30
+ NSString *const EVENT_FILESYSTEM = @"ReactNativeBlobUtilFilesystem";
31
+
32
+ NSString *const MSG_EVENT = @"ReactNativeBlobUtilMessage";
33
+ NSString *const MSG_EVENT_LOG = @"log";
34
+ NSString *const MSG_EVENT_WARN = @"warn";
35
+ NSString *const MSG_EVENT_ERROR = @"error";
36
+ NSString *const FS_EVENT_DATA = @"data";
37
+ NSString *const FS_EVENT_END = @"end";
38
+ NSString *const FS_EVENT_WARN = @"warn";
39
+ NSString *const FS_EVENT_ERROR = @"error";
40
+
41
+ NSString *const KEY_REPORT_PROGRESS = @"reportProgress";
42
+ NSString *const KEY_REPORT_UPLOAD_PROGRESS = @"reportUploadProgress";
43
+
44
+ // response type
45
+ NSString *const RESP_TYPE_BASE64 = @"base64";
46
+ NSString *const RESP_TYPE_UTF8 = @"utf8";
47
+ NSString *const RESP_TYPE_PATH = @"path";
@@ -1,108 +1,108 @@
1
- //
2
- // ReactNativeBlobUtilFS.h
3
- // ReactNativeBlobUtil
4
- //
5
- // Created by Ben Hsieh on 2016/6/6.
6
- // Copyright © 2016年 suzuri04x2. All rights reserved.
7
- //
8
-
9
- #ifndef ReactNativeBlobUtilFS_h
10
- #define ReactNativeBlobUtilFS_h
11
-
12
- #import "ReactNativeBlobUtil.h"
13
- #import <Foundation/Foundation.h>
14
-
15
- #if __has_include(<React/RCTAssert.h>)
16
- #import <React/RCTBridgeModule.h>
17
- #else
18
- #import "RCTBridgeModule.h"
19
- #endif
20
-
21
- #import <AssetsLibrary/AssetsLibrary.h>
22
-
23
- @interface ReactNativeBlobUtilFS : NSObject <NSStreamDelegate> {
24
- NSOutputStream * outStream;
25
- NSInputStream * inStream;
26
- RCTResponseSenderBlock callback;
27
- Boolean isOpen;
28
- NSString * encoding;
29
- int bufferSize;
30
- BOOL appendData;
31
- NSString * taskId;
32
- NSString * path;
33
- NSString * streamId;
34
- }
35
-
36
- @property (nonatomic) NSOutputStream * _Nullable outStream;
37
- @property (nonatomic) NSInputStream * _Nullable inStream;
38
- @property (strong, nonatomic) RCTResponseSenderBlock callback;
39
- @property (nonatomic) NSString * encoding;
40
- @property (nonatomic) NSString * taskId;
41
- @property (nonatomic) NSString * path;
42
- @property (nonatomic) int bufferSize;
43
- @property (nonatomic) NSString * streamId;
44
- @property (nonatomic) BOOL appendData;
45
-
46
- // get dirs
47
- + (NSString *) getCacheDir;
48
- + (NSString *) getDocumentDir;
49
- + (NSString *) getDownloadDir;
50
- + (NSString *) getLibraryDir;
51
- + (NSString *) getMainBundleDir;
52
- + (NSString *) getMovieDir;
53
- + (NSString *) getMusicDir;
54
- + (NSString *) getPictureDir;
55
- + (NSString *) getApplicationSupportDir;
56
- + (NSString *) getTempPath;
57
- + (NSString *) getTempPath:(NSString*)taskId withExtension:(NSString *)ext;
58
- + (NSString *) getPathOfAsset:(NSString *)assetURI;
59
- + (NSString *) getPathForAppGroup:(NSString *)groupName;
60
- + (void) getPathFromUri:(NSString *)uri completionHandler:(void(^)(NSString * path, ALAssetRepresentation *asset)) onComplete;
61
-
62
- // fs methods
63
- + (ReactNativeBlobUtilFS *) getFileStreams;
64
- + (BOOL) mkdir:(NSString *) path;
65
- + (void) mkdir:(NSString *) path resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject;
66
- + (void) hash:(NSString *)path
67
- algorithm:(NSString *)algorithm
68
- resolver:(RCTPromiseResolveBlock)resolve
69
- rejecter:(RCTPromiseRejectBlock)reject;
70
- + (NSDictionary *) stat:(NSString *) path error:(NSError **) error;
71
- + (void) exists:(NSString *) path callback:(RCTResponseSenderBlock)callback;
72
- + (void) writeFileArray:(NSString *)path data:(NSArray *)data append:(BOOL)append resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject;
73
- + (void) writeFile:(NSString *)path encoding:(NSString *)encoding data:(NSString *)data transformFile:(BOOL)transformFile append:(BOOL)append resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject;
74
- + (void) readFile:(NSString *)path encoding:(NSString *)encoding transformFile:(BOOL)transformFile onComplete:(void (^)(NSData * content, NSString* code, NSString * errMsg))onComplete;
75
- + (void) readFile:(NSString *)path encoding:(NSString *)encoding onComplete:(void (^)(NSData * content, NSString* code, NSString * errMsg))onComplete;
76
- + (void) readAssetFile:(NSData *)assetUrl completionBlock:(void(^)(NSData * content))completionBlock failBlock:(void(^)(NSError * err))failBlock;
77
- + (void) slice:(NSString *)path
78
- dest:(NSString *)dest
79
- start:(nonnull NSNumber *)start
80
- end:(nonnull NSNumber *)end
81
- encode:(NSString *)encode
82
- resolver:(RCTPromiseResolveBlock)resolve
83
- rejecter:(RCTPromiseRejectBlock)reject;
84
- //+ (void) writeFileFromFile:(NSString *)src toFile:(NSString *)dest append:(BOOL)append;
85
- + (void) writeAssetToPath:(ALAssetRepresentation * )rep dest:(NSString *)dest;
86
- + (void) readStream:(NSString *)uri encoding:(NSString * )encoding bufferSize:(int)bufferSize tick:(int)tick streamId:(NSString *)streamId baseModule:(ReactNativeBlobUtil *)baseModule;
87
- + (void) df:(RCTResponseSenderBlock)callback;
88
-
89
- // constructor
90
- - (id) init;
91
- - (id)initWithCallback:(RCTResponseSenderBlock)callback;
92
-
93
- // file stream
94
- - (void) openWithDestination;
95
- - (NSString *)openWithPath:(NSString *)destPath encode:(nullable NSString *)encode appendData:(BOOL)append;
96
-
97
- // file stream write data
98
- - (void)write:(NSData *) chunk;
99
- - (void)writeEncodeChunk:(NSString *) chunk;
100
-
101
- - (void) closeInStream;
102
- - (void) closeOutStream;
103
-
104
- - (void) openFile:( NSString * _Nonnull ) uri;
105
-
106
- @end
107
-
108
- #endif /* ReactNativeBlobUtilFS_h */
1
+ //
2
+ // ReactNativeBlobUtilFS.h
3
+ // ReactNativeBlobUtil
4
+ //
5
+ // Created by Ben Hsieh on 2016/6/6.
6
+ // Copyright © 2016年 suzuri04x2. All rights reserved.
7
+ //
8
+
9
+ #ifndef ReactNativeBlobUtilFS_h
10
+ #define ReactNativeBlobUtilFS_h
11
+
12
+ #import "ReactNativeBlobUtil.h"
13
+ #import <Foundation/Foundation.h>
14
+
15
+ #if __has_include(<React/RCTAssert.h>)
16
+ #import <React/RCTBridgeModule.h>
17
+ #else
18
+ #import "RCTBridgeModule.h"
19
+ #endif
20
+
21
+ #import <AssetsLibrary/AssetsLibrary.h>
22
+
23
+ @interface ReactNativeBlobUtilFS : NSObject <NSStreamDelegate> {
24
+ NSOutputStream * outStream;
25
+ NSInputStream * inStream;
26
+ RCTResponseSenderBlock callback;
27
+ Boolean isOpen;
28
+ NSString * encoding;
29
+ int bufferSize;
30
+ BOOL appendData;
31
+ NSString * taskId;
32
+ NSString * path;
33
+ NSString * streamId;
34
+ }
35
+
36
+ @property (nonatomic) NSOutputStream * _Nullable outStream;
37
+ @property (nonatomic) NSInputStream * _Nullable inStream;
38
+ @property (strong, nonatomic) RCTResponseSenderBlock callback;
39
+ @property (nonatomic) NSString * encoding;
40
+ @property (nonatomic) NSString * taskId;
41
+ @property (nonatomic) NSString * path;
42
+ @property (nonatomic) int bufferSize;
43
+ @property (nonatomic) NSString * streamId;
44
+ @property (nonatomic) BOOL appendData;
45
+
46
+ // get dirs
47
+ + (NSString *) getCacheDir;
48
+ + (NSString *) getDocumentDir;
49
+ + (NSString *) getDownloadDir;
50
+ + (NSString *) getLibraryDir;
51
+ + (NSString *) getMainBundleDir;
52
+ + (NSString *) getMovieDir;
53
+ + (NSString *) getMusicDir;
54
+ + (NSString *) getPictureDir;
55
+ + (NSString *) getApplicationSupportDir;
56
+ + (NSString *) getTempPath;
57
+ + (NSString *) getTempPath:(NSString*)taskId withExtension:(NSString *)ext;
58
+ + (NSString *) getPathOfAsset:(NSString *)assetURI;
59
+ + (NSString *) getPathForAppGroup:(NSString *)groupName;
60
+ + (void) getPathFromUri:(NSString *)uri completionHandler:(void(^)(NSString * path, ALAssetRepresentation *asset)) onComplete;
61
+
62
+ // fs methods
63
+ + (ReactNativeBlobUtilFS *) getFileStreams;
64
+ + (BOOL) mkdir:(NSString *) path;
65
+ + (void) mkdir:(NSString *) path resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject;
66
+ + (void) hash:(NSString *)path
67
+ algorithm:(NSString *)algorithm
68
+ resolver:(RCTPromiseResolveBlock)resolve
69
+ rejecter:(RCTPromiseRejectBlock)reject;
70
+ + (NSDictionary *) stat:(NSString *) path error:(NSError **) error;
71
+ + (void) exists:(NSString *) path callback:(RCTResponseSenderBlock)callback;
72
+ + (void) writeFileArray:(NSString *)path data:(NSArray *)data append:(BOOL)append resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject;
73
+ + (void) writeFile:(NSString *)path encoding:(NSString *)encoding data:(NSString *)data transformFile:(BOOL)transformFile append:(BOOL)append resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject;
74
+ + (void) readFile:(NSString *)path encoding:(NSString *)encoding transformFile:(BOOL)transformFile onComplete:(void (^)(NSData * content, NSString* code, NSString * errMsg))onComplete;
75
+ + (void) readFile:(NSString *)path encoding:(NSString *)encoding onComplete:(void (^)(NSData * content, NSString* code, NSString * errMsg))onComplete;
76
+ + (void) readAssetFile:(NSData *)assetUrl completionBlock:(void(^)(NSData * content))completionBlock failBlock:(void(^)(NSError * err))failBlock;
77
+ + (void) slice:(NSString *)path
78
+ dest:(NSString *)dest
79
+ start:(nonnull NSNumber *)start
80
+ end:(nonnull NSNumber *)end
81
+ encode:(NSString *)encode
82
+ resolver:(RCTPromiseResolveBlock)resolve
83
+ rejecter:(RCTPromiseRejectBlock)reject;
84
+ //+ (void) writeFileFromFile:(NSString *)src toFile:(NSString *)dest append:(BOOL)append;
85
+ + (void) writeAssetToPath:(ALAssetRepresentation * )rep dest:(NSString *)dest;
86
+ + (void) readStream:(NSString *)uri encoding:(NSString * )encoding bufferSize:(int)bufferSize tick:(int)tick streamId:(NSString *)streamId baseModule:(ReactNativeBlobUtil *)baseModule;
87
+ + (void) df:(RCTResponseSenderBlock)callback;
88
+
89
+ // constructor
90
+ - (id) init;
91
+ - (id)initWithCallback:(RCTResponseSenderBlock)callback;
92
+
93
+ // file stream
94
+ - (void) openWithDestination;
95
+ - (NSString *)openWithPath:(NSString *)destPath encode:(nullable NSString *)encode appendData:(BOOL)append;
96
+
97
+ // file stream write data
98
+ - (void)write:(NSData *) chunk;
99
+ - (void)writeEncodeChunk:(NSString *) chunk;
100
+
101
+ - (void) closeInStream;
102
+ - (void) closeOutStream;
103
+
104
+ - (void) openFile:( NSString * _Nonnull ) uri;
105
+
106
+ @end
107
+
108
+ #endif /* ReactNativeBlobUtilFS_h */