【发布时间】:2017-01-10 13:02:18
【问题描述】:
我在上传图片时正在实施 Firebase 友好的聊天示例。使用可选字符串获取响应。错过了什么?
Optional(FIRStorageMetadata 0x7fc84aced790: {
bucket = "abc.appspot.com";
contentEncoding = identity;
contentType = "image/jpeg";
downloadTokens = "abctoken";
generation = 1231231;
metageneration = 1;
name = "Optional(\"S5CKnKUykANdxSvZ3wujpMXHTvg1\")/494509700277/asset.JPG";
timeCreated = "2016-09-02T11:49:00.114Z";
updated = "2016-09-02T11:49:00.114Z";
})
我的代码:
let filePath = "(FIRAuth.auth()!.currentUser!.uid)/(Int(NSDate.timeIntervalSinceReferenceDate() * 1000))/(referenceUrl.lastPathComponent!)"
在示例中使用可选值 (?) 编写,因此我将其转换 (!)
【问题讨论】:
-
当你在 firebase 中设置值时.. 那时你发送可选值检查两次
-
该名称是在您将文件上传到 Firebase 存储时创建的。您将需要在此处强制解包可选值。如果您需要这方面的帮助,请发布显示如何将文件上传到 Firebase 存储的最少代码。
-
@FrankvanPuffelen 谢谢。 let filePath = "(FIRAuth.auth()!.currentUser!.uid)/(Int(NSDate.timeIntervalSinceReferenceDate() * 1000))/(referenceUrl.lastPathComponent!)" 在示例中用可选值 (?) 编写,所以我转换它(!)
-
我将代码添加到问题本身,它的可读性更高。如果它不是您的实际代码,请检查并修复(通过单击edit 链接)。
标签: ios firebase firebase-storage