当前位置: 首页>>代码示例>>Java>>正文


Java ContentDisposition类代码示例

本文整理汇总了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;
}
 
开发者ID:SAP,项目名称:cloud-ariba-partner-flow-extension-ext,代码行数:41,代码来源:AttachmentDocumentDao.java

示例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);
}
 
开发者ID:shawn-gogh,项目名称:myjavacode,代码行数:19,代码来源:RestRequestForDiagramViewer.java

示例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);
}
 
开发者ID:ox-it,项目名称:ords-database-api,代码行数:7,代码来源:DatabaseTest.java

示例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;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:6,代码来源:TelegramServiceRestBotAPIAdapter.java


注:本文中的org.apache.cxf.jaxrs.ext.multipart.ContentDisposition类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。