Mic*_*ams 5 ios swift firebase-storage
Xcode会向我抱怨有关将图像上传到Firebase存储的权限的任何原因,但是当我在模拟器中运行相同的应用程序时,它可以正常工作吗?
权限错误:
车身文件无法访问:/var/mobile/Media/DCIM/100APPLE/IMG_0974.JPG错误域= NSCocoaErrorDomain代码= 257"文件'IMG_0974.JPG’无法打开,因为您没有权限查看. " 的UserInfo = {NSURL =文件:///var/mobile/Media/DCIM/100APPLE/IMG_0974.JPG,NSFilePath =在/ var /移动/媒体/ DCIM/100APPLE/IMG_0974.JPG,NSUnderlyingError = {0x14805d680误差区域= NSPOSIXErrorDomain代码= 1"不允许操作"}}
小智 7
我现在遇到同样的问题.上传在模拟器中工作正常,但在设备上它给我权限错误.我的解决方法是将图像上传为数据而不是文件的URL:
let imageData = UIImageJPEGRepresentation(image, 1.0)
let uploadTask = storageReference.child(remoteFilePath).putData(imageData, metadata: metadata, completion: { (metadata, error) in
// Your code here
}
Run Code Online (Sandbox Code Playgroud)