Created
April 21, 2023 21:27
-
-
Save yuriycto/46eb4be2a9e26b0c9fc5e25a29383641 to your computer and use it in GitHub Desktop.
AttachFile.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void AttachFile() | |
{ | |
//Convert your file into BIN format | |
byte[] fileInBytes = Encoding.UTF8.GetBytes("My best ever file."); | |
// Generate info about the file | |
var fileInfo = new PX.SM.FileInfo(Guid.NewGuid(), "OneFile.txt", null, fileInBytes); | |
// Save file to database | |
var uploadFileGraph = PXGraph.CreateInstance<UploadFileMaintenance>(); | |
uploadFileGraph.SaveFile(oneFileInfo, FileExistsAction.CreateVersion); | |
// Attach file to the dedicated table | |
PXNoteAttribute.SetFileNotes(Base.Caches[typeof(DAC)], aRow, fileInfo.UID.Value); uploadFileGraph.Persist(); | |
this.Persist(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment