Content

Ask tech team
From QuickBlox Developers (API docs, code samples, SDK)
Jump to: navigation, search

Contents

Summary

Allows storing rich chat attachments, app content and settings without having to re-publish them. Using a web interface you or your clients can control and make instant changes to the apps.

  • Store chat rich attachments
  • Manage text, rich text, and media via easy to use web admin panel
  • Can be used to manage ads and banners
  • App synchronizes content in background, users not affected
  • Any amount of data can be stored

Need to know information

Before using module Content please read the following:

Content API

Typical use сases

To Upload file you need to do the following:

To Download file you need to do the following:


Requests and Responses

URL HTTP Verb Supported formats Action Description Success HTTP Status Code
/blobs POST
  • xml
  • json
Create a file 201
/blobs GET
  • xml
  • json
Get files list 200
https://qbprod.s3.amazonaws.com POST
  • xml
  • json
Upload a file 201
/blobs/{blob_id}/complete PUT
  • xml
  • json
Declaring file uploaded 200
/blobs/{blob_id} GET
  • xml
  • json
Get information about file by id 200
/blobs/{uid) GET
  • xml
  • json
Download file 200
/blobs/{id)/download GET
  • xml
  • json
Download file 200
/blobs/{blob_id} PUT
  • xml
  • json
Edit file 200
/blobs/{blob_id} DELETE
  • xml
  • json
Delete file 200


Create a file

Create an entity which is a file in a system

Parameters
Param Required Type Value Example Description
blob[content_type] Yes MIMEType (max 50 chars) image/jpeg mime content type
blob[name] Yes String (min 1 chars. max 100 chars) museum File name
blob[public] No String true Blob visibility (by default: false)
blob[tag_list] No String cad,drawing Should be a coma separated string with tags
Request
curl -X POST \
-H "Content-Type: application/json" \
-H "QuickBlox-REST-API-Version: 0.1.0" \
-H "QB-Token: 20e55d804b6bff1cba87cb0215d8967150722ecb" \
-d '{"blob": {"content_type": "image/jpeg", "name": "museum.jpeg"}}' \
http://api.quickblox.com/blobs.json
Response
{
  "blob": {
    "blob_status": null,
    "content_type": "image/jpeg",
    "created_at": "2012-04-23T13:22:34Z",
    "id": 315,
    "last_read_access_ts": null,
    "lifetime": 0,
    "name": "111.jpg",
    "public": false,
    "ref_count": 1,
    "set_completed_at": null,
    "size": null,
    "uid": "30a8bcd7c714417eb62b95350d7e13b900",
    "updated_at": "2012-04-23T13:22:34Z",
    "blob_object_access": {
      "blob_id": 315,
      "expires": "2012-04-23T14:22:34Z",
      "id": 315,
      "object_access_type": "Write",
      "params": "https://qbprod.s3.amazonaws.com/?Content-Type=image%2Fpng&Expires=Wed%2C%2030%20Sep%202015%2013%3A25%3A11%20GMT&acl=authenticated-read&key=fbc2d08125e3435ca5cb37f926d5fe8800&policy=eyJleHBpcmF0aW9uIjoiMjAxNS0wOS0zMFQxMzoyNToxMVoiLCJjb25kaXRpb25zIjpbeyJidWNrZXQiOiJxYnByb2QifSx7ImFjbCI6ImF1dGhlbnRpY2F0ZWQtcmVhZCJ9LHsiQ29udGVudC1UeXBlIjoiaW1hZ2UvcG5nIn0seyJzdWNjZXNzX2FjdGlvbl9zdGF0dXMiOiIyMDEifSx7IkV4cGlyZXMiOiJXZWQsIDMwIFNlcCAyMDE1IDEzOjI1OjExIEdNVCJ9LHsia2V5IjoiZmJjMmQwODEyNWUzNDM1Y2E1Y2IzN2Y5MjZkNWZlODgwMCJ9LHsieC1hbXotY3JlZGVudGlhbCI6IkFLSUFJWTdLRk0yM1hHWEo3UjdBLzIwMTUwOTMwL3VzLWVhc3QtMS9zMy9hd3M0X3JlcXVlc3QifSx7IngtYW16LWFsZ29yaXRobSI6IkFXUzQtSE1BQy1TSEEyNTYifSx7IngtYW16LWRhdGUiOiIyMDE1MDkzMFQxMjI1MTFaIn1dfQ%3D%3D&success_action_status=201&x-amz-algorithm=AWS4-HMAC-SHA256&x-amz-credential=AKIAIY7KFM23XGXJ7R7A%2F20150930%2Fus-east-1%2Fs3%2Faws4_request&x-amz-date=20150930T122511Z&x-amz-signature=a5c720c1a3b9b5c0b2549e0220419493ca3b11ce84618f6ece88ad97a96a8ad9"
    }
  }
}


Get Files List

Get list of files for the current user. The ID of the user is taken from the token specified in the request

Parameters

The request can contain all, some or none of these parameters.

Param Required Type Value Example Description
page No Unsigned Integer 3 Page number of the book of the results that you want to get. By default: 1
per_page No Unsigned Integer 15 The maximum number of results per page. Min: 1. Max: 100. By default: 10


Request
curl -X GET \
-H "QuickBlox-REST-API-Version: 0.1.0" \
-H "QB-Token: 422ce2791d7070b88a82f415b3693c81612e3423" \
http://api.quickblox.com/blobs.json
Response
{
  "current_page": 1,
  "per_page": 10,
  "total_entries": 6,
  "items": [
    {
      "blob": {
        "blob_status": null,
        "content_type": "image/jpeg",
        "created_at": "2012-04-23T13:20:44Z",
        "id": 313,
        "last_read_access_ts": "2012-04-23T14:20:44Z",
        "lifetime": 0,
        "name": "111.jpg",
        "public": false,
        "ref_count": 1,
        "set_completed_at": null,
        "size": null,
        "uid": "29d739b7ff2b4f83bb4cf2416b46238e00",
        "updated_at": "2012-04-23T13:20:44Z"
      }
    },
    ...  
  ]
}


Upload a file

Note: The maximum size of the uploaded file is 100 mb

Upload a file with the params of BlobObjectAccess info to make a possibility to create items with a content.

Parameters

Use params and url from blob-object-access params element from the response for the request of the creation a blob

Request & Response
curl -X POST 
  -F "Content-Type=image/jpeg" 
  -F "Expires=Wed, 30 Sep 2015 13:29:39 GMT" 
  -F "acl=authenticated-read" 
  -F "key=76101edd87fe4b299ff41f63633bf9c100" 
  -F "policy=eyJleHBpcmF0aW9uIjoiMjAxNS0wOS0zMFQxMzoyOTozOVoiLCJjb25kaXRpb25zIjpbeyJidWNrZXQiOiJxYnByb2QifSx7ImFjbCI6ImF1dGhlbnRpY2F0ZWQtcmVhZCJ9LHsiQ29udGVudC1UeXBlIjoiaW1hZ2UvanBnIn0seyJzdWNjZXNzX2FjdGlvbl9zdGF0dXMiOiIyMDEifSx7IkV4cGlyZXMiOiJXZWQsIDMwIFNlcCAyMDE1IDEzOjI5OjM5IEdNVCJ9LHsia2V5IjoiNzYxMDFlZGQ4N2ZlNGIyOTlmZjQxZjYzNjMzYmY5YzEwMCJ9LHsieC1hbXotY3JlZGVudGlhbCI6IkFLSUFJWTdLRk0yM1hHWEo3UjdBLzIwMTUwOTMwL3VzLWVhc3QtMS9zMy9hd3M0X3JlcXVlc3QifSx7IngtYW16LWFsZ29yaXRobSI6IkFXUzQtSE1BQy1TSEEyNTYifSx7IngtYW16LWRhdGUiOiIyMDE1MDkzMFQxMjI5MzlaIn1dfQ==" 
  -F "success_action_status=201" 
  -F "x-amz-algorithm=AWS4-HMAC-SHA256" 
  -F "x-amz-credential=AKIAIY7KFM23XGXJ7R7A/20150930/us-east-1/s3/aws4_request" 
  -F "x-amz-date=20150930T122939Z" 
  -F "x-amz-signature=eee18ae3d47a745bccc9007d1b7b1679e855becb44b1928bb710428e18e397a8" 
  -F "file=@user_new_avatar.jpg"  
https://qbprod.s3.amazonaws.com/
<PostResponse>
  <Location>
    https://blobs-test-oz.s3.amazonaws.com/d5f92bcf84374e4fb8961537f7a7de6500
  </Location>
  <Bucket>blobs-test-oz</Bucket>
  <Key>d5f92bcf84374e4fb8961537f7a7de6500</Key>
  <ETag>"de1aae3e6beadb83bc8e1e21eb7e2a66"</ETag>
</PostResponse>


Declaring file uploaded

Declaring file uploaded. Set file status to 'Complete'. If the specified file size does not match to the actual, the actual will be set

Parameters
Param Required Type Value Example Description
blob[size] Yes Unsigned Integer 123213 Size of uploaded file, in bytes
Request
curl -X PUT \
-H "Content-Type: application/json" \
-H "QuickBlox-REST-API-Version: 0.1.0" \
-H "QB-Token: 74b0087b00d748f944429f1c355b91169f5d9d52" \
-d '{"blob": {"size": "86"}}' \
http://api.quickblox.com/blobs/97/complete.json
Response

Empty body, status: 200

Get information about file by id

Get information about file by ID

Request
curl -X GET \
-H "QuickBlox-REST-API-Version: 0.1.0" \
-H "QB-Token: 6142de6cb6d172227717ae73010dfbb6a07241c5" \
http://api.quickblox.com/blobs/300.json
Response
{
  "blob": {
    "blob_status": "complete",
    "content_type": "image/jpeg",
    "created_at": "2012-04-23T15:23:12Z",
    "id": 300,
    "last_read_access_ts": "2012-04-23T16:26:51Z",
    "lifetime": 0,
    "name": "111.jpg",
    "public": false,
    "ref_count": 1,
    "set_completed_at": "2012-04-23T15:26:51Z",
    "size": 83050,
    "uid": "ce0eae3beadc4232ada7b39316f16bc300",
    "updated_at": "2012-04-23T15:26:51Z"
  }
}


Download File by UID

Download File (Get File as a redirect to the S3 object) by uid. 'uid' is a parameter which should be taken from the response of the request for the creating a file. To have a possibility to download a file you should set a status complete to your file firstly.

If the file is public then it's possible to download it without a session token.

Request
curl -X GET \
-H "QuickBlox-REST-API-Version: 0.1.0" \
-H "QB-Token: 69217f8cfa59ebbb42d610ccb8ac1e55988cadd7" \
http://api.quickblox.com/blobs/358d2cba6ca74127a087530f3e82e8d800.json


Response

301 redirect to file

Download File by ID

Note: this API method is deprecated. Use 'Download File by UID' instead.

Download File (Get File as a redirect to the S3 object) by ID. 'ID' is a parameter which should be taken from the response of the request for the creating a file. To have a possibility to download a file you should set a status complete to your file firstly.

If the file is public then it's possible to download it without a session token.

Request
curl -X GET \
-H "QuickBlox-REST-API-Version: 0.1.0" \
-H "QB-Token: 69217f8cfa59ebbb42d610ccb8ac1e55988cadd7" \
http://api.quickblox.com/blobs/43234/download.json


Response

301 redirect to file


Edit file

Edit a file by ID

Param Required Type Value Example Description
blob[content_type] Optional MIMEType (max 50 chars) image/png Portable Network Graphics; mime content type
blob[name] Optional String (min 1 chars. max 100 chars) GreatPlace File name
blob[tag_list] Optional String cad,drawing Should be a coma separated string with tags
blob[new] Optional Integer 1 Use it to update blob file
Request
curl -X PUT \
-H "Content-Type: application/json" \
-H "QuickBlox-REST-API-Version: 0.1.0" \
-H "QB-Token: 6142de6cb6d172227717ae73010dfbb6a07241c5" \
-d '{"blob": {"name": "GreatPlace"}}' \
http://api.quickblox.com/blobs/101.json
Response
{
  "blob": {
    "blob_status": "complete",
    "content_type": "image/jpeg",
    "created_at": "2012-03-23T08:26:10Z",
    "id": 101,
    "last_read_access_ts": "2012-03-23T09:28:21Z",
    "lifetime": 0,
    "name": "GreatPlace",
    "public": false,
    "ref_count": 2,
    "set_completed_at": "2012-03-23T08:28:22Z",
    "size": 221526,
    "uid": "43b0870a000f4218a8f6a8287c1f65af00",
    "updated_at": "2012-03-23T08:34:17Z"
  }
}


Delete file

Delete file by ID. If there are some referents to the file the number of links will be reduced by 1 after deleting. A file will be deleted in fact when the number of links will be equal to 0.

Request
curl -X DELETE \
-H "QuickBlox-REST-API-Version: 0.1.0" \
-H "QB-Token: 69217f8cfa59ebbb42d610ccb8ac1e55988cadd7" \
http://api.quickblox.com/blobs/97.json
Response

Empty body, status: 200