Method : POST

URI : /brs/<bucket_name>/getfile
/brs/<bucket_name>/getfile?key=<key>&nslice=<nslice>

Body : JSON doc

Workflow to download a file name "aloi" which is present in the bucket "mybucket".

Step 1

Send a request that you are intending to download the file named "aloi".

POST /brs/mybucket/getfile
{
  "access_key": "brs_access_key",
  "secret_key": "brs_secret_key",
  "bucket_name": "mybucket",
  "key": "aloi"
}

The DB will send the following response:

{
  "next_key": "aloi:0:17:17254154:1641803297543410",
  "nslice": 17,
  "chunk_size": 1048576,
  "file_size": 17254154,
  "next_id": 0
}

This tells that file "aloi" is present in the bucket and its size is ~17MB, stored in 17 slices where each slice has chunk size of 1MB. Now we need to start a loop to get all the content, DB will keep helping with the next_key that should be used.

Step 2

First request will be POST request /brs/mybucket/getfile?key=<next_key>&nslice=<nslice>.

The body dummy, "dummy" for example /brs/mybucket/getfile?key=aloi:0:17:17254154:1641803297543410&nslice=17

Step 3

Repeat nslice times

  • Set counter i = 1
  • POST request /brs/mybucket/getfile?key=aloi:i&nslice=17 . The body dummy, "dummy"
  • The server will send response which is base64 encoded chunk of 1MB size
  • Decode the data and write to the end of the file (download file)
  • If error occurs - quit
  • Set i = i+1 and goto beginning of Step 2

Again if you use BangDB CLI or dashboard, these steps are abstracted and you simply run the download or upload command.