本文整理汇总了Java中org.apache.cxf.jaxrs.ext.multipart.ContentDisposition类的典型用法代码示例。如果您正苦于以下问题:Java ContentDisposition类的具体用法?Java ContentDisposition怎么用?Java ContentDisposition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ContentDisposition类属于org.apache.cxf.jaxrs.ext.multipart包,在下文中一共展示了ContentDisposition类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: add
import org.apache.cxf.jaxrs.ext.multipart.ContentDisposition; //导入依赖的package包/类
/**
* Uploads an attachment document in the ECM repository and persists
* document information in the database.
*
* @param eventId
* the id of the event related to the attachment document.
* @param attachment
* the attachment.
* @return
*/
public AttachmentDocument add(String eventId, Attachment attachment) {
logger.debug(DEBUG_CREATING_ATTACHMENT_FOR_EVENT_WITH_EVENT_ID, eventId);
ContentDisposition contentDisposition = attachment.getContentDisposition();
if (contentDisposition == null) {
logger.error(ERROR_CONTENT_DISPOSITION_CANNOT_BE_NULL);
throw new IllegalArgumentException(ERROR_CONTENT_DISPOSITION_CANNOT_BE_NULL);
}
String fileName = contentDisposition.getParameter(FILENAME_PARAMETER);
if (fileName == null) {
logger.error(ERROR_FILE_NAME_CANNOT_BE_NULL);
throw new IllegalArgumentException(ERROR_FILE_NAME_CANNOT_BE_NULL);
}
InputStream inputStream = attachment.getObject(InputStream.class);
Folder eventFolder = ecmRepository.retrieveFolder(ecmRepository.getRootFolder().getPath() + eventId);
if (eventFolder == null) {
logger.debug(DEBUG_CREATING_FOLDER, eventId);
eventFolder = ecmRepository.createFolder(eventId, ecmRepository.getRootFolder());
}
logger.debug(DEBUG_CREATING_DOCUMENT_IN_FOLDER, fileName, eventId);
Document ecmDocument = ecmRepository.createDocument(eventFolder, fileName, inputStream);
logger.debug(DEBUG_PERSISTING_DOCUMENT_INFORMATION_FOR_EVENT_WITH_EVENT_ID, eventId);
AttachmentDocument result = create(toAttachmentDocument(ecmDocument));
logger.debug(DEBUG_CREATED_ATTACHMENT_FOR_EVENT_WITH_EVENT_ID, eventId);
return result;
}
示例2: deployLeave
import org.apache.cxf.jaxrs.ext.multipart.ContentDisposition; //导入依赖的package包/类
/**
* 部署流程
*
* @throws IOException
*/
private static void deployLeave() {
WebClient client = createClient("repository/deployments");
InputStream resourceAsStream = RestRequestTandem.class.getClassLoader().getResourceAsStream("diagrams/leave.bpmn");
client.type("multipart/form-data");
ContentDisposition cd = new ContentDisposition("form-data;name=bpmn;filename=leave.bpmn;");
Attachment att = new Attachment("leave.bpmn", resourceAsStream, cd);
MultipartBody body = new MultipartBody(att);
Response response = client.post(body);
// 转换并输出响应结果
printResult("部署流程", response);
}
示例3: createAttachmentFromFile
import org.apache.cxf.jaxrs.ext.multipart.ContentDisposition; //导入依赖的package包/类
private Attachment createAttachmentFromFile(String filePath, String attachmentName) throws FileNotFoundException {
File file = new File(getClass().getResource(filePath).getFile());
FileInputStream inputStream = new FileInputStream(file);
ContentDisposition cd = new ContentDisposition("attachment;filename="+file.getName());
return new Attachment(attachmentName, inputStream, cd);
}
示例4: buildMediaPart
import org.apache.cxf.jaxrs.ext.multipart.ContentDisposition; //导入依赖的package包/类
private Attachment buildMediaPart(String name, String fileNameWithExtension, byte[] value) {
Attachment a = new Attachment(name, new ByteArrayInputStream(value),
new ContentDisposition("form-data; name=\"" + escapeMimeName(name) + "\"; filename=\"" + escapeMimeName(fileNameWithExtension) + "\""));
return a;
}