【发布时间】:2016-01-29 17:57:30
【问题描述】:
我正在尝试像这样将图像上传到 Firebase:
Firebase *ref = [[Firebase alloc] initWithUrl:@"https://<app-name>.firebaseio.com/posts"];
Firebase *newPost = [ref childByAutoId];
NSDictionary *newPostData = @{
@"image" : [self encodeToBase64String:image]
};
[newPost updateChildValues:newPostData];
我正在使用此代码对图像进行编码:
- (NSString *)encodeToBase64String:(UIImage *)image {
return [UIImagePNGRepresentation(image) base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
}
但这不起作用,因为字符串超过了最大大小:
Terminating app due to uncaught exception 'InvalidFirebaseData', reason: '(updateChildValues:) String exceeds max size of 10485760 utf8 bytes:
我可以做些什么来解决这个问题?使用 Firebase 时,我没有在网上找到任何关于 iOS 开发和图像的信息。
【问题讨论】:
-
我建议将它们上传到图像服务并仅存储 URL。
-
是的,我会这样做的。您是否知道或偏好哪种服务最适合?
标签: ios objective-c uiimage firebase compression