Not sure if this will work but maybe something like this implemented in a java action could perform the desired action:
private static void attachFileToDataset(DataManagementService dmService, Dataset dataset, String filePath) throws NotLoadedException {
File file = new File(filePath);
if (!file.exists()) {
throw new IllegalArgumentException("File does not exist: " + filePath);
}
try {
DataManagement.CreateOrUpdateAttachmentsInput attachmentInput = new DataManagement.CreateOrUpdateAttachmentsInput();
attachmentInput.clientId = "clientId_" + System.currentTimeMillis();
attachmentInput.dataset = dataset;
attachmentInput.filePath = file.getAbsolutePath();
attachmentInput.namedReferenceName = "TEXT"; // Adjust according to dataset type
CreateOrUpdateAttachmentsResponse response = dmService.createOrUpdateAttachments(new DataManagement.CreateOrUpdateAttachmentsInput[]{attachmentInput});
if (response.serviceData.sizeOfPartialErrors() > 0) {
throw new RuntimeException("Error attaching file to dataset: " + response.serviceData.getPartialError(0).getMessages()[0]);
}
} catch (Exception e) {
e.printStackTrace();
}
}