Skip to content

Use storage url from .plist file if not setStorageUrl() hasn't been called #143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 17, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions ios/Firestack/FirestackStorage.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ - (dispatch_queue_t)methodQueue
path:(NSString *) path
callback:(RCTResponseSenderBlock) callback)
{
FIRStorageReference *storageRef = [[FIRStorage storage] referenceForURL:storageUrl];
FIRStorageReference *storageRef;
if (storageUrl == nil ) {
storageRef = [[FIRStorage storage] reference];
} else {
storageRef = [[FIRStorage storage] referenceForURL:storageUrl];
}
FIRStorageReference *fileRef = [storageRef child:path];
[fileRef downloadURLWithCompletion:^(NSURL * _Nullable URL, NSError * _Nullable error) {
if (error != nil) {
Expand All @@ -52,14 +57,13 @@ - (dispatch_queue_t)methodQueue
metadata:(NSDictionary *)metadata
callback:(RCTResponseSenderBlock) callback)
{
FIRStorageReference *storageRef;
if (urlStr == nil) {
NSError *err = [[NSError alloc] init];
[err setValue:@"Storage configuration error" forKey:@"name"];
[err setValue:@"Call setStorageUrl() first" forKey:@"description"];
return callback(@[err]);
storageRef = [[FIRStorage storage] reference];
} else {
storageRef = [[FIRStorage storage] referenceForURL:urlStr];
}

FIRStorageReference *storageRef = [[FIRStorage storage] referenceForURL:urlStr];
FIRStorageReference *uploadRef = [storageRef child:name];
FIRStorageMetadata *firmetadata = [[FIRStorageMetadata alloc] initWithDictionary:metadata];

Expand Down