From 5906d20ce0ec3f0a21651adbf2c1f054bb88970d Mon Sep 17 00:00:00 2001 From: Salakar Date: Thu, 3 May 2018 20:12:46 +0100 Subject: [PATCH] [firestore][ios] implement Blob support --- .../firestore/RNFirebaseFirestoreDocumentReference.m | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ios/RNFirebase/firestore/RNFirebaseFirestoreDocumentReference.m b/ios/RNFirebase/firestore/RNFirebaseFirestoreDocumentReference.m index 6fe78759..49646047 100644 --- a/ios/RNFirebase/firestore/RNFirebaseFirestoreDocumentReference.m +++ b/ios/RNFirebase/firestore/RNFirebaseFirestoreDocumentReference.m @@ -208,6 +208,10 @@ static NSMutableDictionary *_listeners; typeMap[@"type"] = @"number"; } typeMap[@"value"] = value; + } else if ([value isKindOfClass:[NSData class]]) { + typeMap[@"type"] = @"blob"; + NSData *blob = (NSData *)value; + typeMap[@"value"] = [blob base64EncodedStringWithOptions:0]; } else { // TODO: Log an error typeMap[@"type"] = @"null"; @@ -248,6 +252,8 @@ static NSMutableDictionary *_listeners; return [RNFirebaseFirestoreDocumentReference parseJSMap:firestore jsMap:value]; } else if ([type isEqualToString:@"reference"]) { return [firestore documentWithPath:value]; + } else if ([type isEqualToString:@"blob"]) { + return [[NSData alloc] initWithBase64EncodedString:(NSString *) value options:0]; } else if ([type isEqualToString:@"geopoint"]) { NSDictionary *geopoint = (NSDictionary*)value; NSNumber *latitude = geopoint[@"latitude"];