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 help move external files to the cloud, minimize file size growth, and keep 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 to access this Bucket and perform API calls. Please note that the information will only display once, so please make sure to document it.
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 valid for 24 hours; 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 to your BackBlaze account. As with the authentication process, this URL is valid for only 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 200 status code indicating that it was uploaded to your BackBlaze bucket. Additionally, a fileID will be included in the response, which is the file’s unique identifier on your BackBlaze account. You will need this file ID to download that file from BackBlaze.
Additionally, successful uploads should display on your BackBlaze account.
Downloading Files
Using the Download URL from authentication in tandem with the file ID 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 table to store the document names, BackBlaze file IDs, sizes, etc.
Conclusion
BackBlaze’s B2 Cloud Storage API allows you to 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.
Connecting FileMaker to the other tools your business runs on? That's what we do. Â Contact us if you would like help integrating your BackBlaze account with your FileMaker application!
Did you know we are an authorized reseller for Claris FileMaker Licensing?
Contact us to discuss upgrading your Claris FileMaker software.
Download the FileMaker BackBlaze Integration File
Please complete the form below to download your FREE FileMaker file.