Solved

Usage of BLOB format

  • 10 August 2023
  • 2 replies
  • 62 views

Userlevel 2
Badge

Is it possible to re-use of Blob format in acumatica.(E.g:Data.uploadfilerevision table). If So, How?

icon

Best answer by davidnavasardyan09 21 August 2023, 08:45

View original

2 replies

Badge +10

Are you asking how to upload / download a file?

Userlevel 5
Badge +1

@rashmikamudalinayake10 

Yes, it's possible to reuse the Blob format in Acumatica, and there are many use cases where you might want to do so, such as handling file attachments, images, or any binary data. You can use the UploadFileRevision table as a reference.

Here is an example of how you can work with Blob data in Acumatica:

  1. Defining a DAC Field for Blob Data In your DAC, you need a field to hold the Blob data. You can define it like this:
public abstract class blobData : PX.Data.BQL.BqlByteArray.Field<blobData> { }
[PXDBBinary]
public virtual byte[] BlobData { get; set; }

Here, PXDBBinary is used to store binary data, such as a Blob.

  1. Uploading Blob Data To upload Blob data, you can use a file input element in your ASPX page. Here's an example:
<px:PXFileUpload ID="fuBlobData" runat="server" DataField="BlobData" />
  1. Saving Blob Data To save Blob data, you usually don't need to do anything special in your graph since the data binding and the ORM will handle it. When you press the Save button, the data from the PXFileUpload control will be bound to your DAC field, and it will be stored in the database when the record is saved.

  2. Downloading Blob Data If you want to allow users to download the Blob data, you can use the PXRedirectToFileException class. For example:

public PXAction<YourDAC> downloadBlobData;
[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "Download Blob Data")]
public virtual IEnumerable DownloadBlobData(PXAdapter adapter)
{
var currentRecord = YourView.Current;
if (currentRecord != null && currentRecord.BlobData != null)
{
var file = new FileInfo("filename.extension", null, currentRecord.BlobData);
throw new PXRedirectToFileException(file, true);
}
return adapter.Get();
}

 When the user clicks the "Download Blob Data" button, the Blob data will be downloaded to their computer with the specified filename and extension.

  1. Reusing UploadFileRevision Table If you want to reuse the UploadFileRevision table for storing Blob data, you can do so. You can use the UploadFileMaintenance graph to save and retrieve files and their revisions.

Please note that Blob data can be quite large, and storing a lot of it in your database can have performance implications. It's often a good idea to consider other storage options, such as file storage or cloud-based storage, especially for large-scale applications.

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved