Software tips, techniques, and news.

By Andrew Bosworth  Posted on  June 24th, 2020  in  Free Downloads, FileMaker

FileMaker BackBlaze Integration

BackBlaze is a large scale cloud storage platform that currently boasts an impressive 1 billion gigabytes of file data hosted on the cloud and counting. With its competitive pricing, BackBlaze makes a strong case for a place where you can store and retrieve large amounts of data at an affordable rate. Integrating your FileMaker application with BackBlaze’s B2 Cloud Storage API can assist moving external files to the cloud, minimizing file size growth and keeping your FileMaker application lightweight.

What You Need

In addition to owning a BackBlaze account, you will need to create a Bucket on your account page. A Bucket is a location where files can be stored, and you can upload files to the Bucket of your choosing. Following this, you will need to generate an application key with access to this Bucket to perform API calls. Please note that the information will only display once so please make sure to document it.

BackBlaze App Key Information

Authentication

You will need your application key and associated info you received on the BackBlaze account page to authenticate with the BackBlaze B2 Cloud Storage API. Authenticating successfully gives you an Authentication Token, an API Url, and a Download Url. These credentials are only valid for 24 hours, and after that they must be refreshed. Here is an example of a result:

{
  "absoluteMinimumPartSize": 5000000,
  "accountId": "d7afd9e250f5",
  "allowed": {
    "bucketId": "7db75acf7d99eeb275100f15",
    "bucketName": "FileMakerArticle",
    "capabilities": [
      "listBuckets",
      "readBuckets",
      "listFiles",
      "readFiles",
      "shareFiles",
      "writeFiles",
      "deleteFiles"
    ],
    "namePrefix": null
  },
  "apiUrl": "https://api002.backblazeb2.com",
  "authorizationToken": "4_002d7afd9e250f50000000001_01941816_6fa62b_acct_PQ6MJFWUoCp6159-dKFNBzBNM7g=",
  "downloadUrl": "https://f002.backblazeb2.com",
  "recommendedPartSize": 100000000
}

Uploading Files

Using the API Url from the authentication process and its associated credentials, you now need to generate an Upload Url. This Url is used to upload files onto your BackBlaze account. Much like the authentication process, this Url is only valid for 24 hours.

With the Upload Url in hand, you can now push container files from FileMaker into BackBlaze’s cloud storage. Your curl request should look something like this:

"-X POST " & ¶ & "-H \"Authorization: " & $uploadAuthToken & "\"" & ¶ & 
"-H \"X-Bz-File-Name: " & $fileNameEncoded & "\"" & ¶ & 
"-H \"Content-Type: b2/x-auto" & "\"" & ¶ & 
"-H \"X-Bz-Content-Sha1: " & $sha1 & "\"" & ¶ &
"-H \"X-Bz-Info-Author: unknown" & "\"" & ¶ & 
"--data-binary @$container"

A SHA1 Checksum is recommended when uploading your files to BackBlaze. This ensures that the file is not corrupted while in transit between FileMaker and the cloud. You can apply the following FileMaker function to generate a SHA1 checksum on a container.

HexEncode ( CryptDigest ( <<YourContainer>>; "SHA1" ) )

If your file was successfully uploaded, you should receive a response with a status of 200, indicating that your file was successfully uploaded to your bucket on BackBlaze. Additionally, a fileID will be passed alongside the response, which is that file’s unique identifier on your BackBlaze account. You will need this fileID to download that file from BackBlaze.

Additionally, successful uploads should display on your BackBlaze account.

BackBlaze File List Display

Downloading Files

Using the Download Url from authentication in tandem with the fileID from your upload request, you can perform an API call to request a download of a specific file.  In the headers from the response you have access to BackBlaze’s SHA1 checksum as well, so you can compare it against what you have to see if there is any corruption.

Displaying Files In FileMaker

One thing you’ll want to keep in mind when working with the API is that you’ll need to store a representation of all the files as records in your FileMaker solution. In the sample file, we have a file table to store the document names, BackBlaze fileID, size, etc.

FileMaker Backblaze Integration Demo File

Conclusion

BackBlaze’s B2 Cloud Storage API allows you offload large amounts of file data from your FileMaker application to the cloud. With all your files stored on the cloud, you can keep your data size low, while also being able to easily access your files on the web. Contact us if you would like help integrating your BackBlaze account with your FileMaker application!

Did you know we are an authorized reseller for FileMaker Licensing?
Contact us to discuss upgrading your FileMaker software.

Download
Download the FileMaker BackBlaze Integration Database
Please complete the form below to download your FREE FileMaker database file.
FileMaker Experience *
Terms of Use *
OPT-IN: I agree that I am downloading a completely free FileMaker application file with no strings attached. This database is unlocked, and I may use it for my business or organization as I see fit. Because I am downloading a free database, I agree that I should receive occasional marketing. I understand that I can OPT-OUT of these emails at anytime.
Andrew Bosworth thumbnail
Andrew Bosworth

Andrew is an experienced FileMaker developer with a penchant for building things, particularly custom applications to improve business efficiencies.