mirror of
https://github.com/zhigang1992/react-native-firebase.git
synced 2026-06-19 18:23:17 +08:00
Move file methods / constants from storage to utils (#2511)
* stash * move commons into the app * move utils module into app * Update index.d.ts * re-trigger build * fix eslint issues * Fix formatting eslint issues * move utils documentation to app * Dissalow number values in setUserProperties * fix test * add utils export to app module * clean up utils export * Move path helpers to utilities module * I have no idea * Update RNFBUtilsModule.m * remove duplicate util files * fix RNFBUtilsModule merge conflict * fix android build * Move path constants from storage to utils, remove old GH Actions * resolve remaining merge confs * resolve type definition conflict * add requiresMainQueueSetup to RNFBUtilsModule
This commit is contained in:
20
.github/labeler.json
vendored
20
.github/labeler.json
vendored
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"Service: AdMob": "packages/admob/*",
|
||||
"Service: Analytics": "packages/analytics/*",
|
||||
"Service: App/Core": "packages/app/*",
|
||||
"Service: Authentication": "packages/auth/*",
|
||||
"Service: Crashlytics": "packages/crashlytics/*",
|
||||
"Service: Database": "packages/database/*",
|
||||
"Service: Firestore": "packages/firestore/*",
|
||||
"Service: Functions": "packages/functions/*",
|
||||
"Service: Invites": "packages/invites/*",
|
||||
"Service: Links": "packages/links/*",
|
||||
"Service: Messaging": "packages/messaging/*",
|
||||
"Service: Perf": "packages/perf/*",
|
||||
"Service: Remote Config": "packages/config/*",
|
||||
"Service: Storage": "packages/storage/*",
|
||||
"Service: MLKit": "packages/mlkit/*",
|
||||
"Platform: Android": "packages/**/android/*",
|
||||
"Platform: iOS": "packages/**/ios/*",
|
||||
"Platform: JavaScript": "packages/**/lib/*"
|
||||
}
|
||||
18
.github/main.workflow
vendored
18
.github/main.workflow
vendored
@@ -1,18 +0,0 @@
|
||||
workflow "Label PR" {
|
||||
on = "pull_request"
|
||||
resolves = "Labeler"
|
||||
}
|
||||
|
||||
action "Synchronize or Opened" {
|
||||
uses = "actions/bin/filter@master"
|
||||
args = "action 'opened|synchronize'"
|
||||
}
|
||||
|
||||
action "Labeler" {
|
||||
uses = "Asimetriq/github-actions/action-labeler@master"
|
||||
needs = "Synchronize or Opened"
|
||||
env = {
|
||||
LABEL_SPEC_FILE=".github/labeler.json"
|
||||
}
|
||||
secrets = ["GITHUB_TOKEN"]
|
||||
}
|
||||
@@ -13,14 +13,14 @@ App initialization in React Native Firebase is, for the most part, the same as t
|
||||
|
||||
Only some modules on the official Firebase native SDK's support multiple apps, they are as follows:
|
||||
|
||||
- Authentication
|
||||
- Database
|
||||
- Firestore
|
||||
- Functions
|
||||
- Instance ID
|
||||
- Storage
|
||||
- ML Kit Natural Language
|
||||
- ML Kit Vision
|
||||
- Authentication
|
||||
- Database
|
||||
- Firestore
|
||||
- Functions
|
||||
- Instance ID
|
||||
- Storage
|
||||
- ML Kit Natural Language
|
||||
- ML Kit Vision
|
||||
|
||||
For further information, view [Firebase Documentation for Multiple Projects](https://firebase.google.com/docs/web/setup#multiple-projects).
|
||||
|
||||
@@ -60,12 +60,14 @@ const androidConfig = {
|
||||
persistence: true,
|
||||
};
|
||||
|
||||
const kittensApp = firebase.initializeApp(
|
||||
// use platform-specific firebase config
|
||||
Platform.OS === 'ios' ? iosConfig : androidConfig,
|
||||
// name of this app
|
||||
'kittens',
|
||||
).then(app => console.log('initialized apps ->', firebase.apps));
|
||||
const kittensApp = firebase
|
||||
.initializeApp(
|
||||
// use platform-specific firebase config
|
||||
Platform.OS === 'ios' ? iosConfig : androidConfig,
|
||||
// name of this app
|
||||
'kittens',
|
||||
)
|
||||
.then(app => console.log('initialized apps ->', firebase.apps));
|
||||
```
|
||||
|
||||
## Initialize apps via Android/iOS native code
|
||||
@@ -78,12 +80,11 @@ For example, if you created an app natively called `dogs` then the following wou
|
||||
import firebase from '@react-native-firebase/app';
|
||||
|
||||
const dogsApp = firebase.app('dogs');
|
||||
|
||||
```
|
||||
|
||||
## Deleting an app instance
|
||||
|
||||
Firebase App instances can be deleted via `app.delete()`.
|
||||
Firebase App instances can be deleted via `app.delete()`.
|
||||
|
||||
```js
|
||||
await firebase.app('kittens').delete();
|
||||
|
||||
@@ -51,4 +51,3 @@ The instance is also accessible from other installed packages, for example:
|
||||
```js
|
||||
import auth, { firebase } from '@react-native-firebase/auth';
|
||||
```
|
||||
|
||||
|
||||
@@ -43,4 +43,4 @@ for installation instructions on each individual module page.
|
||||
| <Anchor href="/notifications">Notifications</Anchor> | <Badge type="downloads">@react-native-firebase/notifications</Badge> | <Badge type="coverage">notifications</Badge> |
|
||||
| <Anchor href="/perf">Performance Monitoring</Anchor> | <Badge type="downloads">@react-native-firebase/perf</Badge> | <Badge type="coverage">perf</Badge> |
|
||||
| <Anchor href="/database">Realtime Database</Anchor> | <Badge type="downloads">@react-native-firebase/database</Badge> | <Badge type="coverage">database</Badge> |
|
||||
| <Anchor href="/remote-config">Remote Config</Anchor> | <Badge type="downloads">@react-native-firebase/remote-config</Badge> | <Badge type="coverage">remote-config</Badge> |
|
||||
| <Anchor href="/remote-config">Remote Config</Anchor> | <Badge type="downloads">@react-native-firebase/remote-config</Badge> | <Badge type="coverage">remote-config</Badge> |
|
||||
|
||||
@@ -19,7 +19,6 @@ import { utils } from '@react-native-firebase/app';
|
||||
import firebase from '@react-native-firebase/app';
|
||||
|
||||
// firebase.utils().X
|
||||
|
||||
```
|
||||
|
||||
## Utilities
|
||||
@@ -54,4 +53,3 @@ import firebase from '@react-native-firebase/app';
|
||||
// Access the device pictures directory
|
||||
const picturesDir = firebase.utils.FilePath.PICTURES_DIRECTORY;
|
||||
```
|
||||
|
||||
|
||||
@@ -18,21 +18,34 @@ package io.invertase.firebase.utils;
|
||||
*/
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.IntentSender;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import com.facebook.react.bridge.*;
|
||||
import com.google.android.gms.common.ConnectionResult;
|
||||
import com.google.android.gms.common.GoogleApiAvailability;
|
||||
|
||||
import io.invertase.firebase.app.ReactNativeFirebaseApp;
|
||||
import io.invertase.firebase.common.ReactNativeFirebaseModule;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ReactNativeFirebaseUtilsModule extends ReactNativeFirebaseModule {
|
||||
private static final String TAG = "Utils";
|
||||
|
||||
private static final String KEY_MAIN_BUNDLE = "MAIN_BUNDLE";
|
||||
private static final String KEY_DOCUMENT_DIRECTORY = "DOCUMENT_DIRECTORY";
|
||||
private static final String KEY_LIBRARY_DIRECTORY = "LIBRARY_DIRECTORY";
|
||||
private static final String KEY_EXTERNAL_DIRECTORY = "EXTERNAL_DIRECTORY";
|
||||
private static final String KEY_EXT_STORAGE_DIRECTORY = "EXTERNAL_STORAGE_DIRECTORY";
|
||||
private static final String KEY_PICS_DIRECTORY = "PICTURES_DIRECTORY";
|
||||
private static final String KEY_MOVIES_DIRECTORY = "MOVIES_DIRECTORY";
|
||||
private static final String KEY_TEMP_DIRECTORY = "TEMP_DIRECTORY";
|
||||
private static final String KEY_CACHE_DIRECTORY = "CACHES_DIRECTORY";
|
||||
private static final String FIREBASE_TEST_LAB = "firebase.test.lab";
|
||||
|
||||
public ReactNativeFirebaseUtilsModule(ReactApplicationContext reactContext) {
|
||||
@@ -136,8 +149,42 @@ public class ReactNativeFirebaseUtilsModule extends ReactNativeFirebaseModule {
|
||||
@Override
|
||||
public Map<String, Object> getConstants() {
|
||||
Map<String, Object> constants = new HashMap<>();
|
||||
|
||||
constants.put("isRunningInTestLab", isRunningInTestLab());
|
||||
constants.put("androidPlayServices", getPlayServicesStatusMap());
|
||||
|
||||
Context context = getReactApplicationContext();
|
||||
constants.put(KEY_MAIN_BUNDLE, "");
|
||||
constants.put(KEY_LIBRARY_DIRECTORY, context.getFilesDir().getAbsolutePath());
|
||||
constants.put(KEY_TEMP_DIRECTORY, context.getCacheDir().getAbsolutePath());
|
||||
constants.put(KEY_CACHE_DIRECTORY, context.getCacheDir().getAbsolutePath());
|
||||
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
File folder = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS);
|
||||
constants.put(KEY_DOCUMENT_DIRECTORY, folder.getAbsolutePath());
|
||||
} else {
|
||||
constants.put(KEY_DOCUMENT_DIRECTORY, context.getFilesDir().getAbsolutePath());
|
||||
}
|
||||
|
||||
constants.put(KEY_PICS_DIRECTORY, Environment
|
||||
.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
|
||||
.getAbsolutePath());
|
||||
|
||||
constants.put(KEY_MOVIES_DIRECTORY, Environment
|
||||
.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES)
|
||||
.getAbsolutePath());
|
||||
|
||||
File externalStorageDirectory = Environment.getExternalStorageDirectory();
|
||||
if (externalStorageDirectory != null) {
|
||||
constants.put(KEY_EXT_STORAGE_DIRECTORY, externalStorageDirectory.getAbsolutePath());
|
||||
}
|
||||
|
||||
File externalDirectory = context.getExternalFilesDir(null);
|
||||
if (externalDirectory != null) {
|
||||
constants.put(KEY_EXTERNAL_DIRECTORY, externalDirectory.getAbsolutePath());
|
||||
}
|
||||
|
||||
return constants;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,9 +16,15 @@
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <Photos/Photos.h>
|
||||
|
||||
#import <React/RCTBridgeModule.h>
|
||||
|
||||
@interface RNFBUtilsModule : NSObject <RCTBridgeModule>
|
||||
|
||||
+ (BOOL)isRemoteAsset:(NSString *)localFilePath;
|
||||
+ (BOOL)unused_isHeic:(NSString *)localFilePath;
|
||||
+ (NSString *)valueForKey:(NSString *)key fromQueryItems:(NSArray *)queryItems;
|
||||
+ (PHAsset *)fetchAssetForPath:(NSString *)localFilePath;
|
||||
|
||||
@end
|
||||
|
||||
@@ -15,12 +15,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#import <React/RCTUtils.h>
|
||||
#import <Firebase/Firebase.h>
|
||||
#import <React/RCTUtils.h>
|
||||
|
||||
#import "RNFBUtilsModule.h"
|
||||
#import "RNFBApp/RNFBSharedUtils.h"
|
||||
|
||||
#import "RNFBUtilsModule.h"
|
||||
|
||||
@implementation RNFBUtilsModule
|
||||
#pragma mark -
|
||||
@@ -29,10 +28,70 @@
|
||||
RCT_EXPORT_MODULE();
|
||||
|
||||
- (dispatch_queue_t)methodQueue {
|
||||
return dispatch_get_main_queue();
|
||||
return dispatch_get_main_queue();
|
||||
}
|
||||
|
||||
+ (BOOL)requiresMainQueueSetup {
|
||||
return YES;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Firebase Utils Methods
|
||||
|
||||
@end
|
||||
+ (BOOL)isRemoteAsset:(NSString *)localFilePath {
|
||||
return [localFilePath hasPrefix:@"assets-library://"] ||
|
||||
[localFilePath hasPrefix:@"ph://"];
|
||||
}
|
||||
|
||||
+ (BOOL)unused_isHeic:(NSString *)localFilePath {
|
||||
return [[localFilePath pathExtension] caseInsensitiveCompare:@"heic"] ==
|
||||
NSOrderedSame;
|
||||
}
|
||||
|
||||
+ (NSString *)valueForKey:(NSString *)key fromQueryItems:(NSArray *)queryItems {
|
||||
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"name=%@", key];
|
||||
NSURLQueryItem *queryItem =
|
||||
[[queryItems filteredArrayUsingPredicate:predicate] firstObject];
|
||||
return queryItem.value;
|
||||
}
|
||||
|
||||
+ (PHAsset *)fetchAssetForPath:(NSString *)localFilePath {
|
||||
PHAsset *asset;
|
||||
|
||||
if ([localFilePath hasPrefix:@"assets-library://"]) {
|
||||
NSURL *localFile = [[NSURL alloc] initWithString:localFilePath];
|
||||
asset = [[PHAsset fetchAssetsWithALAssetURLs:@[ localFile ]
|
||||
options:nil] firstObject];
|
||||
} else {
|
||||
NSURLComponents *components =
|
||||
[NSURLComponents componentsWithString:localFilePath];
|
||||
NSArray *queryItems = components.queryItems;
|
||||
NSString *assetId = [self valueForKey:@"id" fromQueryItems:queryItems];
|
||||
asset = [[PHAsset fetchAssetsWithLocalIdentifiers:@[ assetId ]
|
||||
options:nil] firstObject];
|
||||
}
|
||||
|
||||
return asset;
|
||||
}
|
||||
|
||||
- (NSString *)getPathForDirectory:(int)directory {
|
||||
NSArray *paths = NSSearchPathForDirectoriesInDomains(
|
||||
(NSSearchPathDirectory)directory, NSUserDomainMask, YES);
|
||||
return [paths firstObject];
|
||||
}
|
||||
|
||||
- (NSDictionary *)constantsToExport {
|
||||
NSMutableDictionary *constants = [@{
|
||||
@"MAIN_BUNDLE" : [[NSBundle mainBundle] bundlePath],
|
||||
@"CACHES_DIRECTORY" : [self getPathForDirectory:NSCachesDirectory],
|
||||
@"DOCUMENT_DIRECTORY" : [self getPathForDirectory:NSDocumentDirectory],
|
||||
@"PICTURES_DIRECTORY" : [self getPathForDirectory:NSPicturesDirectory],
|
||||
@"MOVIES_DIRECTORY" : [self getPathForDirectory:NSMoviesDirectory],
|
||||
@"TEMP_DIRECTORY" : NSTemporaryDirectory(),
|
||||
@"LIBRARY_DIRECTORY" : [self getPathForDirectory:NSLibraryDirectory],
|
||||
} mutableCopy];
|
||||
|
||||
return constants;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -80,11 +80,11 @@ export default {
|
||||
SDK_VERSION: require('./../version'),
|
||||
get FilePath() {
|
||||
// TODO move from storage native code into utils native code
|
||||
return processPathConstants(NativeModules.RNFBStorageModule);
|
||||
return processPathConstants(NativeModules.RNFBUtilsModule);
|
||||
},
|
||||
// TODO(salakar) deprecated remove in 6.1.0:
|
||||
get Native() {
|
||||
// TODO move from storage native code into utils native code
|
||||
return processPathConstants(NativeModules.RNFBStorageModule);
|
||||
return processPathConstants(NativeModules.RNFBUtilsModule);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
*/
|
||||
|
||||
import { isIOS } from '../../lib/common';
|
||||
import UtilsStatics from './UtilsStatics';
|
||||
import { createModuleNamespace, FirebaseModule } from '../../lib/internal';
|
||||
import UtilsStatics from './UtilsStatics';
|
||||
|
||||
const namespace = 'utils';
|
||||
const statics = UtilsStatics;
|
||||
|
||||
@@ -19,16 +19,11 @@ package io.invertase.firebase.storage;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
|
||||
import com.facebook.react.bridge.Arguments;
|
||||
import com.facebook.react.bridge.Promise;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactMethod;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.bridge.WritableArray;
|
||||
import com.facebook.react.bridge.WritableMap;
|
||||
import com.google.android.gms.tasks.Task;
|
||||
import com.google.firebase.FirebaseApp;
|
||||
import com.google.firebase.storage.FirebaseStorage;
|
||||
@@ -36,7 +31,6 @@ import com.google.firebase.storage.ListResult;
|
||||
import com.google.firebase.storage.StorageMetadata;
|
||||
import com.google.firebase.storage.StorageReference;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -52,15 +46,6 @@ import static io.invertase.firebase.storage.ReactNativeFirebaseStorageCommon.pro
|
||||
|
||||
public class ReactNativeFirebaseStorageModule extends ReactNativeFirebaseModule {
|
||||
private static final String TAG = "Storage";
|
||||
private static final String KEY_MAIN_BUNDLE = "MAIN_BUNDLE";
|
||||
private static final String KEY_DOCUMENT_DIRECTORY = "DOCUMENT_DIRECTORY";
|
||||
private static final String KEY_LIBRARY_DIRECTORY = "LIBRARY_DIRECTORY";
|
||||
private static final String KEY_EXTERNAL_DIRECTORY = "EXTERNAL_DIRECTORY";
|
||||
private static final String KEY_EXT_STORAGE_DIRECTORY = "EXTERNAL_STORAGE_DIRECTORY";
|
||||
private static final String KEY_PICS_DIRECTORY = "PICTURES_DIRECTORY";
|
||||
private static final String KEY_MOVIES_DIRECTORY = "MOVIES_DIRECTORY";
|
||||
private static final String KEY_TEMP_DIRECTORY = "TEMP_DIRECTORY";
|
||||
private static final String KEY_CACHE_DIRECTORY = "CACHES_DIRECTORY";
|
||||
|
||||
ReactNativeFirebaseStorageModule(ReactApplicationContext reactContext) {
|
||||
super(reactContext, TAG);
|
||||
@@ -319,36 +304,6 @@ public class ReactNativeFirebaseStorageModule extends ReactNativeFirebaseModule
|
||||
Map<String, Object> constants = new HashMap<>();
|
||||
|
||||
Context context = getReactApplicationContext();
|
||||
constants.put(KEY_MAIN_BUNDLE, "");
|
||||
constants.put(KEY_LIBRARY_DIRECTORY, context.getFilesDir().getAbsolutePath());
|
||||
constants.put(KEY_TEMP_DIRECTORY, context.getCacheDir().getAbsolutePath());
|
||||
constants.put(KEY_CACHE_DIRECTORY, context.getCacheDir().getAbsolutePath());
|
||||
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
File folder = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS);
|
||||
constants.put(KEY_DOCUMENT_DIRECTORY, folder.getAbsolutePath());
|
||||
} else {
|
||||
constants.put(KEY_DOCUMENT_DIRECTORY, context.getFilesDir().getAbsolutePath());
|
||||
}
|
||||
|
||||
constants.put(KEY_PICS_DIRECTORY, Environment
|
||||
.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
|
||||
.getAbsolutePath());
|
||||
|
||||
constants.put(KEY_MOVIES_DIRECTORY, Environment
|
||||
.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES)
|
||||
.getAbsolutePath());
|
||||
|
||||
File externalStorageDirectory = Environment.getExternalStorageDirectory();
|
||||
if (externalStorageDirectory != null) {
|
||||
constants.put(KEY_EXT_STORAGE_DIRECTORY, externalStorageDirectory.getAbsolutePath());
|
||||
}
|
||||
|
||||
File externalDirectory = context.getExternalFilesDir(null);
|
||||
if (externalDirectory != null) {
|
||||
constants.put(KEY_EXTERNAL_DIRECTORY, externalDirectory.getAbsolutePath());
|
||||
}
|
||||
|
||||
// a 'safe' way of checking if any apps have been initialized
|
||||
List<FirebaseApp> apps = FirebaseApp.getApps(context);
|
||||
|
||||
@@ -21,33 +21,10 @@
|
||||
|
||||
#import "RNFBStorageCommon.h"
|
||||
#import "RNFBSharedUtils.h"
|
||||
#import "RNFBUtilsModule.h"
|
||||
|
||||
@implementation RNFBStorageCommon
|
||||
|
||||
+ (BOOL)isRemoteAsset:(NSString *)localFilePath {
|
||||
return [localFilePath hasPrefix:@"assets-library://"] || [localFilePath hasPrefix:@"ph://"];
|
||||
}
|
||||
|
||||
+ (BOOL)unused_isHeic:(NSString *)localFilePath {
|
||||
return [[localFilePath pathExtension] caseInsensitiveCompare:@"heic"] == NSOrderedSame;
|
||||
}
|
||||
|
||||
+ (PHAsset *)fetchAssetForPath:(NSString *)localFilePath {
|
||||
PHAsset *asset;
|
||||
|
||||
if ([localFilePath hasPrefix:@"assets-library://"]) {
|
||||
NSURL *localFile = [[NSURL alloc] initWithString:localFilePath];
|
||||
asset = [[PHAsset fetchAssetsWithALAssetURLs:@[localFile] options:nil] firstObject];
|
||||
} else {
|
||||
NSURLComponents *components = [NSURLComponents componentsWithString:localFilePath];
|
||||
NSArray *queryItems = components.queryItems;
|
||||
NSString *assetId = [self valueForKey:@"id" fromQueryItems:queryItems];
|
||||
asset = [[PHAsset fetchAssetsWithLocalIdentifiers:@[assetId] options:nil] firstObject];
|
||||
}
|
||||
|
||||
return asset;
|
||||
}
|
||||
|
||||
+ (NSData *)NSDataFromUploadString:(NSString *)string format:(NSString *)format {
|
||||
if ([format isEqualToString:@"base64"]) {
|
||||
return [[NSData alloc] initWithBase64EncodedString:string options:0];
|
||||
@@ -71,12 +48,6 @@
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (NSString *)valueForKey:(NSString *)key fromQueryItems:(NSArray *)queryItems {
|
||||
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"name=%@", key];
|
||||
NSURLQueryItem *queryItem = [[queryItems filteredArrayUsingPredicate:predicate] firstObject];
|
||||
return queryItem.value;
|
||||
}
|
||||
|
||||
+ (NSString *)utiToMimeType:(NSString *)dataUTI {
|
||||
return (__bridge_transfer NSString *) UTTypeCopyPreferredTagWithClass((__bridge CFStringRef) dataUTI,
|
||||
kUTTagClassMIMEType);
|
||||
@@ -106,8 +77,8 @@
|
||||
NSURL *temporaryFileUrl,
|
||||
NSString *contentType
|
||||
))completion {
|
||||
if ([RNFBStorageCommon isRemoteAsset:localFilePath]) {
|
||||
PHAsset *asset = [RNFBStorageCommon fetchAssetForPath:localFilePath];
|
||||
if ([RNFBUtilsModule isRemoteAsset:localFilePath]) {
|
||||
PHAsset *asset = [RNFBUtilsModule fetchAssetForPath:localFilePath];
|
||||
NSURL *temporaryFileUrl = [RNFBStorageCommon createTempFileUrl];
|
||||
[RNFBStorageCommon downloadAsset:asset toURL:temporaryFileUrl completion:^(
|
||||
NSArray *errorCodeMessageArray,
|
||||
|
||||
@@ -530,21 +530,8 @@ RCT_EXPORT_METHOD(setTaskStatus:
|
||||
}];
|
||||
}
|
||||
|
||||
- (NSString *)getPathForDirectory:(int)directory {
|
||||
NSArray *paths = NSSearchPathForDirectoriesInDomains((NSSearchPathDirectory) directory, NSUserDomainMask, YES);
|
||||
return [paths firstObject];
|
||||
}
|
||||
|
||||
- (NSDictionary *)constantsToExport {
|
||||
NSMutableDictionary *constants = [@{
|
||||
@"MAIN_BUNDLE": [[NSBundle mainBundle] bundlePath],
|
||||
@"CACHES_DIRECTORY": [self getPathForDirectory:NSCachesDirectory],
|
||||
@"DOCUMENT_DIRECTORY": [self getPathForDirectory:NSDocumentDirectory],
|
||||
@"PICTURES_DIRECTORY": [self getPathForDirectory:NSPicturesDirectory],
|
||||
@"MOVIES_DIRECTORY": [self getPathForDirectory:NSMoviesDirectory],
|
||||
@"TEMP_DIRECTORY": NSTemporaryDirectory(),
|
||||
@"LIBRARY_DIRECTORY": [self getPathForDirectory:NSLibraryDirectory],
|
||||
} mutableCopy];
|
||||
NSMutableDictionary *constants = [@{} mutableCopy];
|
||||
|
||||
if ([[[FIRApp allApps] allKeys] count] > 0) {
|
||||
FIRStorage *storageInstance = [FIRStorage storage];
|
||||
|
||||
@@ -722,4 +722,4 @@ SPEC CHECKSUMS:
|
||||
|
||||
PODFILE CHECKSUM: 0142c48fc8ad8e230e216fc15af267405c520250
|
||||
|
||||
COCOAPODS: 1.7.2
|
||||
COCOAPODS: 1.7.5
|
||||
|
||||
Reference in New Issue
Block a user