36
Appendix B: Managing Files
QuickBase applications can support file attachment storage and file attachment access through the API’s file
upload and download feature. Files are “attached” through a record field that has the type File Attachment.
File attachments are stored in a special database that is separate from the QuickBase application database.
That means they won’t take up space in the QuickBase application database.
This section describes the typical upload scenario where access to the local file system is available if needed.
If your environment cannot make use of the local file system, you may need to use the API_UploadFile call.
Uploading files
Files are uploaded as file attachments to a record during an API_AddRecord or API_EditRecord call. The file
field you use for file attachments must be of type File Attachment.
The file must be base64-encoded. You should not use MIME style encoding with newline characters at a
maximum line length of 76. Instead, QuickBase requires you omit these newlines. (If you don’t omit the
newlines, the stored file in QuickBase won’t be usable.)
Because of the typical file sizes, you won’t be able to upload files using a URL. You must POST the encoded
file as XML.
Downloading files
You can download a file in two ways:
•
If you know the database ID, the record ID, the Field ID of the file field you are attaching to, and the
version ID, you can use issue a GET request using this URL format:
https://quickbase.com/up/DBID/a/rRID/eFID/vVID
where:
DBID is your TABLE dbid (not the application dbid)
RID is the rid of the record with the File attachment
FID is the fid of the File attachment field,
VID is the version ID of the file. Specifying 0 (zero) for the VID always gets you the most recent version.
For example: https://quickbase.com/up/bdb5rjd6h/a/r13/e8/v0
•
If you know the URL of the file attachment, you can issue a GET request that contains the URL of the file
attachment and the table dbid. (To get the URL, use API_DoQuery if and set its fmt parameter to
“structured.” The URL is returned in the <url></url> tags.)
Here’s a typical URL that you would use in this second way of doing a GET:
https://quickbase.com/up/bdb5rjd6g/g/rz/ey/va/Model_T.jpg
Note: If you use file attachments, you should understand how QuickBase versions files. See the QuickBase
online help for more information.
Page 235