Getting Started

 View Only
  • 1.  How to download File attachments using API ?

    Posted 07-06-2022 07:15
    I am trying to download the files from my Quickbase table using the download file API (https://developer.quickbase.com/operation/downloadFile), but I only get the data in base64 format. How do I download the file itself ?

    ------------------------------
    Hemanth
    ------------------------------


  • 2.  RE: How to download File attachments using API ?

    Posted 07-06-2022 09:57
    You need to decode the base64 into a byte string and write it to a file i am not sure what language you are using but in python it would look something like this

    dl_file = //get you file from quickbase
    
    //assuming the file is a png image
    import base64
    with open("img.png", "wb") as fh:
        fh.write(base64.decodebytes(dl_file))
    ​


    ------------------------------
    Simon H
    ------------------------------



  • 3.  RE: How to download File attachments using API ?

    Posted 07-06-2022 11:14
    I am using PowerShell. The file is a AES KEY, used to encrypt confidential data. When I convert from Base64, it seems to be adding some extra characters at the beginning. 

    Is there a way to download the file itself, rather than getting the data in Base64 format ?

    ------------------------------
    Hemanth H.
    ------------------------------



  • 4.  RE: How to download File attachments using API ?

    Posted 07-08-2022 11:40
    You are downloading the file itself, however it is base64 encoded.
    Are you simply decoding it and reading it in to your script?

    keep i mind that it is not base64 encoded TEXT which can simply be decoded and read as is
    it is a file which means there is other metadata encoded in there as well.
    You might be doing this
    https://base64.guru/converter/decode/text
    When you should be doing this
    https://base64.guru/converter/decode/file

    I have a working python solution but i am not familiar with poweshell. you can try the solution found here to write to a file
    https://stackoverflow.com/questions/35334928/convert-base64-string-to-file
    and then open the file to ensure it matches exactly.


    ------------------------------
    Simon H
    ------------------------------