ios - Firebase storage error -
firebasestorage pod version (1.0.1)
var storageref: firstoragereference! = firstorage.storage().reference() let uploadtask = storageref.putdata(uiimagepngrepresentation(image)!, metadata: nil) { metadata, error in if (error != nil) { } else { let downloadurl = metadata!.downloadurl print(downloadurl) } }
i selected image imagepicker , tried save image data firebase storage. illustrated in firebase docs.(docs reference) upload data in memory section.
it's throwing following error:
*** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '*** -[__nsplaceholderdictionary initwithobjects:forkeys:count:]: attempt insert nil object objects[1]' *** first throw call stack: ( 0 corefoundation 0x02025494 __exceptionpreprocess + 180 1 libobjc.a.dylib 0x03eb2e02 objc_exception_throw + 50 2 corefoundation 0x01f0c6d2 -[__nsplaceholderdictionary initwithobjects:forkeys:count:] + 386 3 corefoundation 0x01f2095b +[nsdictionary dictionarywithobjects:forkeys:count:] + 75 4 fireplay 0x001e42bc -[firstorageuploadtask enqueue] + 815 5 fireplay 0x001e010c -[firstoragereference putdata:metadata:completion:] + 880
the same code used work before. not sure what's problem now.
turns out can't put files in root storage node. need create child node , can save file. mentioned in firebase docs somehow overlooked it.
e.g
let mountainsref = storageref.child("mountains.jpg") let uploadtask = mountainsref.putdata(uiimagepngrepresentation(image)!, metadata: nil) { metadata, error in if (error != nil) { } else { let downloadurl = metadata!.downloadurl print(downloadurl) } }
Comments
Post a Comment