Getting Started

 View Only
  • 1.  How to upload and download image/files with quickbase

    Posted 10-25-2020 20:39
    Am trying to upload/Download an Image or a file using Quickbase  Json Restful API. what is the best  way to do that.

    Below is two options i have tried

    1.) I upload the file to external server while saving the file name to quick base. The field type for this text field.

    2.) I converted the image file to base64 encode via php and then created a field type File Attachment. The issue here is that base64 encoded files cannot be saved to quickbase via Restful API Json Call with field type set to File Attachment.
    here is how I did it with php
    <?php
    $file = 'photo.png';
    $encode_File = base64_encode(file_get_contents($file));
    ?>

    What is the best way to upload/download files via QB Json Restful API

    ------------------------------
    Fredrick Esedo
    ------------------------------


  • 2.  RE: How to upload and download image/files with quickbase

    Posted 10-27-2020 16:03
    Edited by Nathan Hawe 10-27-2020 16:09
    Fredrick, you can upload the base64 encoded file through the RESTful API.  My PHP is rusty, but you'd do it similar to this:
    <?PHP // This assumes that the field ID for the file attachment field is 6 and that // $table_id, $host, and $user_token are defined earlier in the script. $file = 'photo.png'; $encode_file = base64_encode(file_get_contents($file)); $request_body = json_encode(array( "to" => $tableId, "data" => array( array( "6" => array( "value" => array( "fileName" => $file, "data" => $encode_file ) ) ) ) )); $request = curl_init("https://api.quickbase.com/v1/records"); curl_setopt( $request, CURLOPT_HTTPHEADER, array( 'QB-REALM-HOSTNAME: ' . $host, 'AUTHORIZATION: QB-USER-TOKEN ' . $user_token, 'Content-Type: application/json' ) ); curl_setopt($request, CURLOPT_POSTFIELDS, $request_body); ?>​
    ------------------------------
    Nathan Hawe
    ------------------------------