Quickblox IOS文件上传坏了吗?

时间:2015-06-28 09:53:53

标签: ios image file upload quickblox

经过几个小时的尝试,我真的陷入了以下困境。我使用Quickblox SDK(版本2.3.0.1)

尝试将文件上传到Custom对象时,我不断收到“错误的参数错误”。在较旧的api中,这非常好(但在当前版本中,QBCustomObjects类已经消失了)

以下是我的工作:

if(_fileData == nil){
    NSLog(@"filedata is nil");
}else{
    NSLog(@"filedata is not nil %lu",(unsigned long)[_fileData length]);
}

QBCOFile *file = [QBCOFile file];
file.name = @"test";
file.contentType = @"image/jpeg";
file.data = _fileData;

[QBRequest uploadFile:file className:@"event_pictures" objectID:co.ID fileFieldName:@"picture" successBlock:^(QBResponse *response, QBCOFileUploadInfo *info) {
    // uploaded
    [self saveToCacheAndReturn];

} statusBlock:^(QBRequest *request, QBRequestStatus *status) {
    // handle progress
    dispatch_async(dispatch_get_main_queue(), ^{
        _progressBlock(status.percentOfCompletion);
    });
} errorBlock:^(QBResponse *response) {
    // error handling
    NSLog(@"Response error UPLOAD FILE: %@", [response.error description]);
    [self returnWithError:[response.error description]];
}];

来自api的回应是:

2015-06-28 11:46:05.789 getAlife[1245:180976] Request URL:https://api.quickblox.com/data/event_pictures/558dac31535c12e0fc02b549/file.json?field_name=picture
2015-06-28 11:46:05.789 getAlife[1245:180976] Request method: POST
2015-06-28 11:46:05.790 getAlife[1245:180976] Request headers: {
    "QB-SDK" = "iOS 2.3.0.1";
    "QB-Token" = 561b0b3af86d95f70aeec7c912a5ceedf2e90189;
    "QuickBlox-REST-API-Version" = "0.1.1";
}
2015-06-28 11:46:05.972 getAlife[1245:180976] Response headers: {
    "Access-Control-Allow-Origin" = "*";
    "Cache-Control" = "no-cache";
    Connection = "keep-alive";
    "Content-Type" = "application/json; charset=utf-8";
    Date = "Sun, 28 Jun 2015 09:47:32 GMT";
    "QB-Token-ExpirationDate" = "2015-06-28 11:47:13 UTC";
    "QuickBlox-REST-API-Version" = "0.1.1";
    Server = "nginx/1.0.15";
    Status = "404 Not Found";
    "Transfer-Encoding" = Identity;
    "X-Rack-Cache" = "invalidate, pass";
    "X-Request-Id" = 0f0ab7ee264201d3a522493c633a6591;
    "X-Runtime" = "0.017728";
    "X-UA-Compatible" = "IE=Edge,chrome=1";
}
2015-06-28 11:46:05.973 getAlife[1245:176514] Response error UPLOAD FILE: 
   Error reasons:{
    errors =     (
        "Wrong arguments"
    );
}

我检查了数据是否为nil,如果设置了权限,如果对象存在于类中。奇怪的是,旧命令完美无缺:

[QBCustomObjects uploadFile:file className:@"event_pictures" objectID:co.ID fileFieldName:@"picture" delegate:self context:@"uploadFile"];

请您告诉我该怎么办才能让它再次运转? 提前谢谢。

event_pictures的类架构是:

{

  /* unique record identificator (read-only) */
  "_id":                "55a409fb535c1215fc003b9d",

  /* parent object ID */
  "_parent_id":         null,

  /* object creation timestamp (read-only) */
  "created_at":         1436813819,

  /* File */
  "picture":            null,

  /* String */
  "recurrenceId":       "1436813819WojVC5V0LQ",

  /* object updating timestamp (read-only) */
  "updated_at":         1436813819,

  /* object owner (can be set to any existing user id) */
  "user_id":            3844090
}

该类的所有权限都设置为“打开”。

0 个答案:

没有答案