1
0
-1

Greetings,

 

According to the documentation, the getFileUploadData() method from the com.avoka.fc.core.entity.FileUploadData object is deprecated.

what's the alternative?

I need to retrieve the byte[] data from a form attachment and the method above seems not to rise compilation errors but the resulting file seems to be corrupted. Therefore, I would assume while I manage to get all the attachment properties, the byte array representing the file doesn't work using the "getFileUploadData()" method.

Here's the code I'm currently using

 

def arrFormAttachments = submission.getAttachments()
for (formAttach in arrFormAttachments) {
def singleFileUpload = (com.avoka.fc.core.entity.FileUpload) formAttach.getFileUpload()
def fileName = singleFileUpload.getFileName()
def filePath = myCustomPath + fileName
def fileOuputStream = new FileOutputStream(filePath);
fileOuputStream.write(singleFileUpload.getFileUploadData().getFileUploadData());
fileOuputStream.close(); 

}

 

Any help would be appreciated.

My version details:

Transaction Manager 4.1.5
Build Number 40001

Thank you,

Carles

    CommentAdd your comment...

    1 answer

    1.  
      2
      1
      0

      Hi Carles,

       

      Please use below instead.

       

      ISubmissionDataStorageService submissionDataStorageService = ServiceLocator.getSubmissionDataStorageService(submission);

      byte[] bytes = submissionDataStorageService.getAttachment(singleFileUpload);

      1. Carles Tierno

        Hi Nirmal, Many thanks for your reply. The proposed code threw a compilation error but I finally managed to get the bytes from the attachment using the line below byte[] FileBytes = submissionDataDao.getAttachment(singleFileUpload) The output stream resulting file got correctly constructed and it could be opened nornally. Many thanks for your help!

      CommentAdd your comment...