(API) Managing your medias

This tutorial is in order to manage your medias using the version 1.0 of Sandbox Botdoc API. In order to use this version, you have to put “v1” on the API’s endpoint.

To a better understanding about the versioning, please go to api.botdoc.io/documentation/#versioning
and to a better understanding about the Sandbox, please go to api.botdoc.io/documentation/#sandbox-platform

Instructions

  1. Getting your medias:
    In order to get a list of your medias you have to make a request to https://api.botdoc.io/v1/media/ as GET and you can use 2 parameters (just like getting your requests):
    page to return the result set based on this page number (starting from 1, not 0), and page_size that is the number of results per page.

    If you don’t pass any parameter, page‘s default is 1 and page_size‘s default is 10.

    If you send a request as GET like this: https://api.botdoc.io/v1/media/

    The response will look like the example below:
    e.g.

    { "links":{ "previous":null, "next":"https://api.botdoc.io/v1/?media=2" }, "total_pages":2, "count":12, "results":[ { "id":5, "name":"Weeding_certificate.png", "content_type":"image/png", "bytes":20283, "extension":"png", "file":"65637392e6956cf74f575ac9e9faf7a0.png", "total_chunks":1, "metadata":{ "remote_addr":"172.19.0.1" }, "created":"2020-08-14T17:36:44.641834Z", "updated":"2020-08-14T17:36:57.847042Z", "current_chunk":1, "file_checksum":"34c395e123b3b4d7e0ecc36b18833c8e", "removed_at":null, "removed_requested_from":null, "media_download":[ ], "times_downloaded":0, "state":"available", "download_link_data_collection":"http://127.0.0.1:8000/v1/module_container_pushpull/mediadatacollection/5/download/", "max_allowed_times_downloaded":6, "tag":"Weeding Certificate", "request":1080 } ] }


    The response is similar as getting your requests, of course, the results will be medias instead of requests.

  2. Getting a specific media:
    In order to get a specific media you have to make a request to https://api.botdoc.io/v1/media/{media_id}/ as GET and the response will look like the example below:
    e.g.

    { "id": 5, "name": "Weeding_certificate.png", "content_type": "image/png", "bytes": 20283, "extension": "png", "file": "65637392e6956cf74f575ac9e9faf7a0.png", "total_chunks": 1, "metadata": { "remote_addr": "172.19.0.1" }, "created": "2020-08-14T17:36:44.641834Z", "updated": "2020-08-14T17:36:57.847042Z", "current_chunk": 1, "file_checksum": "34c395e123b3b4d7e0ecc36b18833c8e", "removed_at": null, "removed_requested_from": null, "media_download": [], "times_downloaded": 0, "state": "available", "download_link_data_collection": "http://127.0.0.1:8000/v1/module_container_pushpull/mediadatacollection/5/download/", "max_allowed_times_downloaded": 6, "tag": "Weeding Certificate", "request": 1080 }


    This endpoint does NOT retrieve the file’s content. In order to do so, you have to use the endpoint below, Download media.

  3. Download a media:
    In order to download a specific media you have to make a request to https://api.botdoc.io/v1/media/{media_id}/download/ as GET 


    The body response is the file’s content.

  4. Delete a media:
    Botdoc automatically deletes the medias, but you can delete earlier if you don’t want to wait.

    In order to delete a specific media you have to make a request to https://api.botdoc.io/v1/media/{media_id}/ as DELETE


    The response will be the HTTP Code 204 when the deleting is successful.

  5.  Create a media:
    You can create a media to a existing request in order to send files. You can take a look at our tutorial Sending your first requests on the 7th step.

    Here is some cURL to create a media in our API:

    curl -i --request POST "https://api.botdoc.io/v1/media/" \ --header "Authorization: JWT <Autorization key>" \ --form "file=@C:\curl\image.png" \ --form "request={container_id}" \ --form "current_chunk=1" \ --form "total_chunks=1"

FULL VIEW CLICK HERE