2

I need to create form to upload file from client side to server in AX 2012 R3 using X++.

Can some one give me link / example regarding this issue?

I try to search and find that I can use class SysFileStoreManager, but still confused how to use it.

Jonathan Bravetti
  • 2,228
  • 2
  • 15
  • 29
julius
  • 75
  • 11

1 Answers1

4

You can find example use of SysFileStoreManager using the Cross-reference Tool. I find it a bit bloated.

You can do this:

static client container getPackedFileClient(FileName _fileNameClient) 
{
    BinData binData = new BinData();
    binData.loadFile(_fileNameClient);
    return binData.getData();
}

This is the SysFileStoreManager.getPackedFileClient method, but without the protected keyword.
To save the file:

static server container saveFileToServer(container _packedFile, Filename _filename)
{
    #File
    BinData b = new BinData();
    b.setData(_packedFile);
    new FileIOPermission(_filename, #IO_WRITE).assert();
    b.saveFile(_filename);
}

This is SysFileStoreManager.copyFileToClient_Client adapted for general use. You can the call the methods in sequence:

saveFileToServer(getPackedFileClient(clienFileName), serverFileName);

The file content is transferred from client to server using a container.

Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50