I need to create a custom attachment provider to keep attachments in a disk file instead of using the folders inside mwm.
I cannot find how to implement it. I created a provider extending com.webMethods.caf.faces.data.attachments.TempAttachmentsProvider but I cannot make it work with other stuff other than the folders inside the MWM server.
I need also to be able to create subfolders dynamically (the same way that createTempFolder() does).
Please see the attached example.
There is a function that iterates through the temp attachment provider and writes the files to disk (on a per user basis) inside the MWS temp directory. I imagine that you’ll want to write to different directories, so you should be able to alter as needed, but the sample does demonstrate creating directories as well:
public void uploadDocs() throws Exception {
String dirPath = PathUtil.appendPath(FileUtil.getTempDirectory(), getFacesContext().getExternalContext().getRemoteUser());
File dir = new File(dirPath);
dir.mkdir();
//loop through attachments and write them to the filesystem
List<IAttachmentItem> files = getTemporaryAttachmentsProvider().listAttachments();
for (IAttachmentItem file: files){
String path = PathUtil.appendPath(dir.toString(), file.getFileName());
File f = new File(path);
try {
log("writing: " + file.getFileItem().getName());
FileOutputStream fos = new FileOutputStream(f);
InputStream fis = file.getFileItem().getInputStream();
FileUtil.copyStream(fis, fos);
} catch (Exception e) {
log(e);
}
}
}
The load part works right, I’m working through the listAttachment() method now and it works right but I can some problem with displaying the icons corresponding to each file in the attachment panel.
I’m trying to figure out if there is a way to move a file to the MWS server, expose it, and still have access control such that only the creator can see it. I’ve tried the attachement appraach but it’s too clever for my needs.
Streaming it works great (see: My Other Thread) but I’m afraid with large PDFs the Data URI limitations will come into play …or maybe I’m misunderstanding them.
Sravan, yes that is developed for 8.2 designer. However, it doesn’t use 8.2 specific features so i think you should be able to examine the .java and the .view file to replicate this in 7.x Designer.
Very helpful discussion indeed. But from the below Attachment provider implementation, only icon is getting displayed without any hyperlink or download popup(Or even save link as option). So how can i modify so that, if the user directly left clicks on attachment it should prompt Save as popup and if he right clicks on it, it should give Save as option to copy the file in local system.