如何将文件更新到QuickBlox iOS中的内容模块

时间:2016-02-07 18:34:08

标签: ios iphone quickblox

在内容模块中上传图片后如何更新图片? 我在下面的代码上传文件代码

// Upload a file to the Content module
NSData *imageData = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"image45" ofType:@"png"]];

[QBRequest TUploadFile:imageData fileName:@"arrow.png" contentType:@"image/png" isPublic:NO successBlock:^(QBResponse *response, QBCBlob *uploadedBlob) {
    // set dialog's photo
    NSUInteger uploadedFileID = uploadedBlob.ID;
    dialog.photo = [NSString stringWithFormat:@"%d", uploadedFileID];
} statusBlock:^(QBRequest *request, QBRequestStatus *status) {
    // handle progress            
} errorBlock:^(QBResponse *response) {
    NSLog(@"error: %@", response.error);
}];

1 个答案:

答案 0 :(得分:2)

查找更新内容文件的此代码

NSData *file = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"plus" ofType:@"png"]];

QBCBlob *blob = [QBCBlob blob];
blob.ID = 65268; // ID of exists file
blob.name = @"Plus";
[QBRequest TUpdateFileWithData:file file:blob successBlock:^(QBResponse *response) {
    // File updated
    // if blob.isPublic == YES
    NSString *url = [blob publicUrl];
} statusBlock:^(QBRequest *request, QBRequestStatus *status) {
    // handle progress            
} errorBlock:^(QBResponse *response) {
    NSLog(@"error: %@", response.error);
}];