Loading ...

Reusing the BLOB Format in Acumatica: A Practical Guide

Storing and handling binary data—like PDFs, images, or other file attachments—is a common requirement in business applications. Acumatica provides full support for working with BLOBs (Binary Large Objects), and the good news is, you can reuse and customize this capability in your own DACs and screens. Whether you're building file upload features, managing image records, or exporting embedded files, understanding how to work with BLOBs gives you a flexible foundation for binary data handling in Acumatica.

Defining a BLOB Field in a DAC

To begin, you’ll need a field in your DAC to store binary data. Acumatica uses the [PXDBBinary] attribute to mark BLOB fields.

Here’s how you define it:

public abstract class blobData : PX.Data.BQL.BqlByteArray.Field<blobData> { }

 

[PXDBBinary]

public virtual byte[] BlobData { get; set; }

 

This field can store any binary data—images, documents, or anything else represented as a byte array. Once this is in place, you can bind it to a file upload control in the UI.

Uploading BLOB Data in the UI

To allow users to upload a file, you can use the PXFileUpload control in your ASPX page. This control handles file uploads automatically and binds them to your DAC’s binary field.

Example usage in ASPX:

<px:PXFileUpload ID="fuBlobData" runat="server" DataField="BlobData" />

When a user selects a file and saves the record, Acumatica automatically binds the uploaded file’s binary content to the BlobData field. You don’t need to write any special code in the graph to store the file—it’s handled by the framework’s data binding system.

 

Downloading BLOB Data

You can also allow users to download files stored in the BLOB field using a PX action and the PXRedirectToFileException. Here’s a simple example:

When the user clicks the "Download Blob Data" button, the browser prompts them to save the file with the specified filename and extension. This approach works for any type of binary content stored in the DAC.

 

Reusing the UploadFileRevision Table

Acumatica already includes the UploadFileRevision table to manage uploaded files and their versions. You can reuse this table to store binary files in a more standardized way, especially if you want to support versioning or reference attachments across documents.

To save and retrieve files in this format, you can work with the UploadFileMaintenance graph. This graph handles file uploads, metadata, and revisions efficiently, and you can integrate it into your own logic if needed.

For example:

PX.SM.UploadFileMaintenance uploadGraph = PXGraph.CreateInstance<PX.SM.UploadFileMaintenance>();

uploadGraph.SaveFile(file); // where file is of type PX.SM.FileInfo

This is ideal if you're building a custom attachment module and want to align with Acumatica's native file management strategy.

 

Performance Consideration

Keep in mind: binary data can grow fast. If your application expects frequent uploads of large files (e.g., high-resolution images or PDFs), consider the implications of storing all that binary data inside the SQL database. In those cases, integrating with external file storage (such as Azure Blob Storage or Amazon S3) may be a better long-term strategy.


Final Thoughts

Working with BLOB data in Acumatica is simple and powerful. You can define binary fields in your DAC, use standard UI controls to upload files, and provide download options via a clean API. Whether you’re embedding small documents or building a larger file management module, Acumatica gives you the flexibility to handle binary data in a way that scales with your application’s needs.

If your use case gets more advanced, consider leveraging Acumatica's UploadFileRevision and UploadFileMaintenance tools to centralize and standardize file handling. With a few lines of code and smart use of the platform, you can provide users with rich file management capabilities—right inside Acumatica.

Be the first to rate this post

  • Currently 0.0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5