can someone help with a standalone code which can download the files on the attachments tab of a change ?

can someone help with a standalone code which can download the files on the attachments tab of a change object in Oracle Agile PLM 9.3.6 and store it to my local pc location ? The code to download all the files of any type uploaded on the change object ?

 

Add Comment
1 Answer(s)

Iterator attItr = change.getTable(ItemConstants.TABLE_ATTACHMENTS).iterator();

while (attItr.hasNext()) {
IRow row = (IRow) attItr.next();

String fileName = row.getValue(new Integer(“1046”)).toString();

File file = new File(MAIN_PATH+fileName);

System.out.println(“Downloading “+fileName+” from “+change.getName());

InputStream stream = ((IAttachmentFile) row).getFile();

try (FileOutputStream outputStream = new FileOutputStream(file, false)) {
int read;
byte[] bytes = new byte[8192];
while ((read = stream.read(bytes)) != -1) {
outputStream.write(bytes, 0, read);
}
}
}

Agile User Answered on July 11, 2022.

Instead of writting byte by byte we can try IOUtils.Copy method as well

on November 17, 2022.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.