QuickBlox Documentation

QuickBlox provides powerful Chat API and SDK to add real-time messaging and video calls to your web and mobile apps. Learn how to integrate QuickBlox across multiple platforms and devices. Check out our detailed guides to make integration easy and fast.

Content

Learn how to store and access files with QuickBlox file storage.

The content module allows storing rich chat attachments, app content, and settings without having to republish them. Using a web interface you or your clients can control and make instant changes to the apps.

Retrieve files

Get a list of files for a current user using the code snippet below.

// these parameters are optional
var params = {
  page: 1,
  per_page: 10
};

QB.content.list(params, function(err, data) {
  // ...
});

// equivalent of the above code
QB.content.list(function(err, data) {
  // ...
});

Upload file

Upload a file to the cloud storage using the following code snippet.

var input = document.querySelector("input[type=file]");
var file = input.files[0];

var params = {
  name: file.name,
  file: file,
  type: file.type,
  size: file.size,
  public: false // optional, "false" by default
};

QB.content.createAndUpload(params, function(err, response) {
  if (err) {
    console.log(err);
  } else {
    console.log(response);
    var uploadedFile = response;
    var uploadedFileId = response.id;
  }
});

Download file by UID

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

QB.content.getFile('file uid', function (err, file) {
  // ...
})

Get file URL

Except for downloading, you can also get URL of each file. There are two types of file URLs that can be obtained: private and public.

  • Public URL allows anyone to access the file, no authorization token is needed.
  • Private URL can be accessed only by QuickBlox user with a session token.

Get public URL

To receive a public URL, use the code snippet below.

var fileUID = 'file uid';

var fileUrl = QB.content.publicUrl(fileUID);

Get private URL

To get a private URL of the uploaded file, use the following code snippet.

var fileUID = 'file uid';

var fileUrl = QB.content.privateUrl(fileUID);

Updated 2 months ago



Content


Learn how to store and access files with QuickBlox file storage.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.