use of com.zimbra.cs.service.mail.UploadScanner in project zm-mailbox by Zimbra.
the class SaveDocument method getUploadedDoc.
protected Doc getUploadedDoc(String uploadId, ZimbraSoapContext zsc, String name, String ct, String description) throws ServiceException {
ZimbraLog.mailbox.info("uploadId=%s", uploadId);
Upload up = FileUploadServlet.fetchUpload(zsc.getAuthtokenAccountId(), uploadId, zsc.getAuthToken());
// scan upload for viruses
//StringBuffer is used here rather than a StringBuilder as UploadScanner could potentially be multi-threaded.
StringBuffer info = new StringBuffer();
UploadScanner.Result result = UploadScanner.accept(up, info);
if (result == UploadScanner.REJECT)
throw MailServiceException.UPLOAD_REJECTED(up.getName(), info.toString());
if (result == UploadScanner.ERROR)
throw MailServiceException.SCAN_ERROR(up.getName());
Doc doc = new Doc(up, name, ct, description);
return doc;
}
Aggregations