我试图处理用户在应用程序离线时尝试上传和映像时会发生什么。有时它运行起来并且firebase完成了一个域错误并且我能够创建一个上传任务,但是,如果设备离线并且我得到一条不在firebase文档中的日志消息,最近永远不会调用完成块。
以下是上传图片的代码:
[self.storageRef child:imagePath] putData:imageData metadata:fileMeta
completion:^(FIRStorageMetadata * _Nullable metadata, NSError * _Nullable error) {
if (error) {
NSLog(@"Error uploading: %@", error);
//create local task
[self createUploadTaskForCurrentUserWithContentType:fileMeta.contentType filePath:imagePath isPhoto:NO];
return;
}
NSLog(@"Project image upload successful");
}];
这是我在将互联网重新联机后 的日志消息:
2017-03-08 15:57:27.513 TEST[15661:822730] unexpected response data (uploading to the wrong URL?)
{
"name": "-KejhLQPdFBNfyWyqCfS/1489006585133.jpg",
"bucket": "test-8822d.appspot.com",
"generation": "1489006647755852",
"metageneration": "1",
"contentType": "image/jpeg",
"timeCreated": "2017-03-08T20:57:27.683Z",
"updated": "2017-03-08T20:57:27.683Z",
"storageClass": "STANDARD",
"size": "169509",
"md5Hash": "5ZYpGG7d7jUthRIlM6yTAg==",
"contentEncoding": "identity",
"contentDisposition": "inline; filename*=utf-8''1489006585133.jpg",
"crc32c": "4+FzAg==",
"etag": "CMyIu4Lmx9ICEAE=",
"downloadTokens": "570aa9ec-d97d-4e82-8feb-c8688f9d67c8"
}
注意:这在联机时工作正常,唯一的问题是当我尝试在离线时运行代码时。