Search code examples
ios7quickblox

reading headers from Quickblox in iOS


I'm downloading 2 types of files from Content module, pics and videos. How can I read received headers "Content-Type" (image/jpg or video/mp4) inside my app and be able to act accordingly to file type?

This is what I can read in console:

**

<QBASIHTTPRequest: 0xe10bc00>
headers:{
    "Accept-Ranges" = bytes;
    "Content-Length" = 361902;
    **"Content-Type" = "image/jpg";**
    Date = "Wed, 06 Nov 2013 11:27:35 GMT";
    Etag = "\"2b685b3ebfa38317a5dc8551db743028\"";
    "Last-Modified" = "Wed, 06 Nov 2013 11:27:19 GMT";
    Server = AmazonS3;
    "x-amz-id-2" = "uta4GqIvFbTzZxIqbw3xRSker5vz7T1+d/9T7E2JNylsIiGNoLLm1fWwNq0FDjUz";
    "x-amz-request-id" = 66F8735545490417;
}

**


Solution

  • Finally got it!

    QBCFileDownloadTaskResult has a blob property and all you need to do is read its contentType like:

    if(result.success && [result isKindOfClass:QBCFileDownloadTaskResult.class]){
    
            QBCFileDownloadTaskResult *res = (QBCFileDownloadTaskResult *)result;
    
            QBCBlob *blob = res.blob;
            NSString *contentType = blob.contentType;
    }
    

    Hope it can be useful for someone searching for the same.