Hi,
it is very usual question, here is short example, Acumatica saves information about attachment in one table, and file as BIN array in another table, investigate UploadFileMaintenance graph in Acumatica’s source code and you will find tables.
Example:
public class CREmailActivityMaintExt : PXGraphExtension<CREmailActivityMaint>
{
public void TEST()
{
byte[] allFilesInByte = new byte[1000]; // here must be your file in BIN data
FileInfo oneFileInfo = new FileInfo(Guid.NewGuid(), "OneFile.txt", null, allFilesInByte);
UploadFileMaintenance fileUploadGraph = PXGraph.CreateInstance<UploadFileMaintenance>();
fileUploadGraph.SaveFile(oneFileInfo, FileExistsAction.CreateVersion);
PXNoteAttribute.AttachFile(Base.Message.Cache, Base.Message.Current, oneFileInfo);
fileUploadGraph.Persist();
this.Base.Persist();
throw new PXRedirectToFileException(oneFileInfo.UID, false); // it is redirection to file attachments screen
}
}