• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MultipartBody类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.cxf.jaxrs.ext.multipart.MultipartBody的典型用法代码示例。如果您正苦于以下问题:Java MultipartBody类的具体用法?Java MultipartBody怎么用?Java MultipartBody使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MultipartBody类属于org.apache.cxf.jaxrs.ext.multipart包,在下文中一共展示了MultipartBody类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: uploadSmallAccessFile

import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入依赖的package包/类
@Test ()
public void uploadSmallAccessFile() throws FileNotFoundException {
	loginBasicUser();

	WebClient client = getClient(false);
	client.type("multipart/form-data");
	
	Attachment att = createAttachmentFromFile("/mondial.accdb", "dataFile");
	client = getClient(false);
	client.type("multipart/form-data");
	Response response = client.path("/"+logicalDatabaseId+"/data/test").post(new MultipartBody(att));
	assertEquals(201, response.getStatus());		

	String id = getIdFromResponse(response);
	DatabaseReference r = new DatabaseReference(Integer.parseInt(id), false);
	AbstractResourceTest.databases.add(r);
}
 
开发者ID:ox-it,项目名称:ords-database-api,代码行数:18,代码来源:DatabaseTest.java


示例2: uploadSmallSQLFile

import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入依赖的package包/类
@Test ()
public void uploadSmallSQLFile() throws Exception {
	loginBasicUser();
	
	WebClient client = getClient(false);
	client.type("multipart/form-data");
	
	Attachment att = createAttachmentFromFile("/databases/main_2812_2811.sql", "dataFile");
	client = getClient(false);
	client.type("multipart/form-data");
	Response response = client.path("/"+logicalDatabaseId+"/data/test").post(new MultipartBody(att));
	assertEquals(201, response.getStatus());	

	String id = getIdFromResponse(response);
	DatabaseReference r = new DatabaseReference(Integer.parseInt(id), false);
	AbstractResourceTest.databases.add(r);

}
 
开发者ID:ox-it,项目名称:ords-database-api,代码行数:19,代码来源:DatabaseTest.java


示例3: uploadSmallCSVFile

import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入依赖的package包/类
@Test ()
public void uploadSmallCSVFile() throws Exception {
	loginBasicUser();
	
	WebClient client = getClient(false);
	client.type("multipart/form-data");
	
	Attachment att = createAttachmentFromFile("/small_test.csv", "dataFile");

	Response response = client.path("/"+logicalDatabaseId+"/data/test").post(new MultipartBody(att));
	assertEquals(201, response.getStatus());
	
	String id = getIdFromResponse(response);
	DatabaseReference r = new DatabaseReference(Integer.parseInt(id), false);
	AbstractResourceTest.databases.add(r);
	
	logout();
}
 
开发者ID:ox-it,项目名称:ords-database-api,代码行数:19,代码来源:DatabaseTest.java


示例4: appendCSVToTableWithHeader

import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入依赖的package包/类
@Test ()
public void appendCSVToTableWithHeader() throws Exception {
	loginBasicUser();
	
	WebClient client = getClient(false);
	client.type("multipart/form-data");
	
	Attachment att = createAttachmentFromFile("/append_start.csv", "dataFile");
	
	Response response = client.path("/"+logicalDatabaseId+"/data/test").post(new MultipartBody(att));
	assertEquals(201, response.getStatus());
	
	String id = getIdFromResponse(response);
	DatabaseReference r = new DatabaseReference(Integer.parseInt(id), false);
	AbstractResourceTest.databases.add(r);
	
	// append
	
	client = getClient(false);
	client.type("multipart/form-data");
	att = createAttachmentFromFile("/append_continue.csv", "dataFile");
	response = client.path("/"+id+"/append/table/append_start/true/test").post(new MultipartBody(att));
	assertEquals(201, response.getStatus());
}
 
开发者ID:ox-it,项目名称:ords-database-api,代码行数:25,代码来源:DatabaseTest.java


示例5: appendCSVToTableInvalid

import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入依赖的package包/类
@Test ()
public void appendCSVToTableInvalid ( ) throws Exception {
	loginBasicUser();
	
	WebClient client = getClient(false);
	client.type("multipart/form-data");
	
	Attachment att = createAttachmentFromFile("/append_start.csv", "dataFile");
	
	Response response = client.path("/"+logicalDatabaseId+"/data/test").post(new MultipartBody(att));
	assertEquals(201, response.getStatus());
	
	String id = getIdFromResponse(response);
	DatabaseReference r = new DatabaseReference(Integer.parseInt(id), false);
	AbstractResourceTest.databases.add(r);
	
	// append
	
	client = getClient(false);
	client.type("multipart/form-data");
	att = createAttachmentFromFile("/append_continue_different.csv", "dataFile");
	response = client.path("/"+id+"/append/table/append_start/true/test").post(new MultipartBody(att));
	assertEquals(409, response.getStatus());	
}
 
开发者ID:ox-it,项目名称:ords-database-api,代码行数:25,代码来源:DatabaseTest.java


示例6: appendCSVToTableNoHeader

import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入依赖的package包/类
@Test ()
public void appendCSVToTableNoHeader ( ) throws Exception {
	loginBasicUser();
	
	WebClient client = getClient(false);
	client.type("multipart/form-data");
	
	Attachment att = createAttachmentFromFile("/append_start.csv", "dataFile");
	
	Response response = client.path("/"+logicalDatabaseId+"/data/test").post(new MultipartBody(att));
	assertEquals(201, response.getStatus());
	
	String id = getIdFromResponse(response);
	DatabaseReference r = new DatabaseReference(Integer.parseInt(id), false);
	AbstractResourceTest.databases.add(r);
	
	// append
	
	client = getClient(false);
	client.type("multipart/form-data");
	att = createAttachmentFromFile("/append_continue_no_header.csv", "dataFile");
	response = client.path("/"+id+"/append/table/append_start/false/test").post(new MultipartBody(att));
	assertEquals(201, response.getStatus());	
}
 
开发者ID:ox-it,项目名称:ords-database-api,代码行数:25,代码来源:DatabaseTest.java


示例7: appendCSVToTableNoHeaderInvalid

import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入依赖的package包/类
@Test ()
public void appendCSVToTableNoHeaderInvalid ( ) throws Exception {
	loginBasicUser();
	
	WebClient client = getClient(false);
	client.type("multipart/form-data");
	
	Attachment att = createAttachmentFromFile("/append_start.csv", "dataFile");
	
	Response response = client.path("/"+logicalDatabaseId+"/data/test").post(new MultipartBody(att));
	assertEquals(201, response.getStatus());
	
	String id = getIdFromResponse(response);
	DatabaseReference r = new DatabaseReference(Integer.parseInt(id), false);
	AbstractResourceTest.databases.add(r);
	
	// append
	
	client = getClient(false);
	client.type("multipart/form-data");
	att = createAttachmentFromFile("/append_continue_different_no_header.csv", "dataFile");
	response = client.path("/"+id+"/append/table/append_start/false/test").post(new MultipartBody(att));
	assertEquals(409, response.getStatus());	
}
 
开发者ID:ox-it,项目名称:ords-database-api,代码行数:25,代码来源:DatabaseTest.java


示例8: exportUnauth

import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入依赖的package包/类
@Test
public void exportUnauth ( ) throws Exception {
	loginBasicUser();
	
	WebClient client = getClient(false);
	client.type("multipart/form-data");
	
	Attachment att = createAttachmentFromFile("/small_test.csv", "dataFile");

	Response response = client.path("/"+logicalDatabaseId+"/data/test").post(new MultipartBody(att));
	assertEquals(201, response.getStatus());
	
	String id = getIdFromResponse(response);
	DatabaseReference r = new DatabaseReference(Integer.parseInt(id), false);
	AbstractResourceTest.databases.add(r);	
	
	logout();
	
	client = getClient(true);
	client.accept("application/sql");
	String exportPath = "/"+id+"/export/sql";
	response = client.path(exportPath).get();
	assertEquals(403, response.getStatus());

}
 
开发者ID:ox-it,项目名称:ords-database-api,代码行数:26,代码来源:DatabaseTest.java


示例9: noSqlDataPut

import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入依赖的package包/类
@POST
@Path("/nosql/data/put/{id}")
public String noSqlDataPut(@PathParam("id") String id, MultipartBody body) throws IOException {

    byte[] data = null;
    String filename = null;
    if (Constants.PLACEHOLDER_NEW_FILE.equals(id))
        id = UUID.randomUUID().toString();

    for (Attachment attachment : body.getAllAttachments()) {
        if (Constants.FIELD_DATA.equalsIgnoreCase(attachment.getContentDisposition().getParameter(Constants.MULTIPART_FIELD_NAME))) {
            filename = attachment.getContentDisposition().getParameter(Constants.MULTIPART_FIELD_FILENAME);
            data = Utils.getBytes(attachment.getDataHandler().getInputStream());
        }
    }

    logger.info("Archive file id  : " + id);
    logger.info("Archive file name: " + filename);

    if (!NoSqlEngine.noSqlPutData(id, data)) {
        logger.error("Failed to store data [" + id + "]");
    }

    return id;
}
 
开发者ID:yeleid,项目名称:archive,代码行数:26,代码来源:ArchiveService.java


示例10: updateBinaryVariable

import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入依赖的package包/类
@PUT
@Path("/{processInstanceId}/variables/{variableName}")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response updateBinaryVariable(@PathParam("processInstanceId") String processInstanceId,
                                     @PathParam("variableName") String variableName,
                                     MultipartBody multipartBody) {

    Execution execution = getExecutionInstanceFromRequest(processInstanceId);

    RestVariable result;
    try {
        result = setBinaryVariable(multipartBody, execution, RestResponseFactory.VARIABLE_PROCESS, false);
    } catch (IOException | ServletException e) {
        throw new BPMNRestException("Exception occured during creating binary execution variable", e);
    }

    return Response.ok().entity(result).build();
}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:20,代码来源:ProcessInstanceService.java


示例11: createBinaryExecutionVariable

import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入依赖的package包/类
@POST
@Path("/{processInstanceId}/variables")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response createBinaryExecutionVariable(@PathParam("processInstanceId") String processInstanceId, @Context
HttpServletRequest httpServletRequest, MultipartBody multipartBody) {

    Execution execution = getExecutionInstanceFromRequest(processInstanceId);
    Response response;
    try {
        response = createBinaryExecutionVariable(execution, false, RestResponseFactory
                .VARIABLE_PROCESS, multipartBody);
    } catch (IOException | ServletException e) {
        throw new BPMNRestException("Exception occured during creating binary execution variable", e);
    }
    return response;
}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:18,代码来源:ProcessInstanceService.java


示例12: createOrUpdateBinaryExecutionVariable

import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入依赖的package包/类
@PUT
@Path("/{processInstanceId}/variables")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response createOrUpdateBinaryExecutionVariable(@PathParam("processInstanceId") String processInstanceId,
                                                      MultipartBody multipartBody) {

    Execution execution = getExecutionInstanceFromRequest(processInstanceId);
    Response response;
    try {
        response = createBinaryExecutionVariable(execution, true, RestResponseFactory.VARIABLE_PROCESS,
                multipartBody);
    } catch (IOException | ServletException e) {
        throw new BPMNRestException("Exception occured during creating execution variable", e);
    }
    return response;
}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:18,代码来源:ProcessInstanceService.java


示例13: createBinaryTaskVariable

import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入依赖的package包/类
@POST
@Path("/{taskId}/variables")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response createBinaryTaskVariable(@PathParam("taskId") String taskId, MultipartBody multipartBody) {

    Task task = getTaskFromRequest(taskId);
    Object result = null;
    try {
        result = setBinaryVariable(multipartBody, task, true, uriInfo);
    } catch (IOException e) {
        throw new ActivitiIllegalArgumentException("Error Reading variable attachment", e);
    }

    if (result != null) {
        return Response.ok().status(Response.Status.CREATED).build();
    } else {
        throw new ActivitiIllegalArgumentException("Binary Task variable creation failed");
    }

}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:22,代码来源:WorkflowTaskService.java


示例14: updateBinaryTaskVariable

import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入依赖的package包/类
@PUT
@Path("/{taskId}/variables/{variableName}")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response updateBinaryTaskVariable(@PathParam("taskId") String taskId, @PathParam("variableName") String variableName,
                                         MultipartBody multipartBody) {
    Task task = getTaskFromRequest(taskId);
    RestVariable result = null;
    try {
        result = setBinaryVariable(multipartBody, task, false, uriInfo);
    } catch (IOException e) {
        throw new ActivitiIllegalArgumentException("Error Reading variable attachment", e);
    }
    if (result != null) {
        if (!result.getName().equals(variableName)) {
            throw new ActivitiIllegalArgumentException("Variable name in the body should be equal to the name used in the requested URL.");
        }
    }

    return Response.ok().entity(result).build();
}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:22,代码来源:WorkflowTaskService.java


示例15: uploadUnsupportedFile

import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入依赖的package包/类
@Test ()
public void uploadUnsupportedFile() throws FileNotFoundException {
	loginBasicUser();

	WebClient client = getClient(false);
	client.type("multipart/form-data");
	
	Attachment att = createAttachmentFromFile("/config.xml", "dataFile");
	Response response = client.path("/"+logicalDatabaseId+"/data/test").post(new MultipartBody(att));
	assertEquals(415, response.getStatus());
}
 
开发者ID:ox-it,项目名称:ords-database-api,代码行数:12,代码来源:DatabaseTest.java


示例16: uploadCSVFileUnauth

import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入依赖的package包/类
@Test ()
public void uploadCSVFileUnauth() throws FileNotFoundException {
	WebClient client = getClient(false);
	client.type("multipart/form-data");
	
	Attachment att = createAttachmentFromFile("/small_test.csv", "dataFile");
	Response response = client.path("/"+logicalDatabaseId+"/data/test").post(new MultipartBody(att));
	assertEquals(403, response.getStatus());
}
 
开发者ID:ox-it,项目名称:ords-database-api,代码行数:10,代码来源:DatabaseTest.java


示例17: uploadAccessFileUnauth

import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入依赖的package包/类
@Test ()
public void uploadAccessFileUnauth() throws FileNotFoundException {
	WebClient client = getClient(false);
	client.type("multipart/form-data");
	
	Attachment att = createAttachmentFromFile("/mondial.accdb", "dataFile");
	client = getClient(false);
	client.type("multipart/form-data");
	Response response = client.path("/"+logicalDatabaseId+"/data/test").post(new MultipartBody(att));
	assertEquals(403, response.getStatus());
}
 
开发者ID:ox-it,项目名称:ords-database-api,代码行数:12,代码来源:DatabaseTest.java


示例18: appendCSVToDatabase

import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入依赖的package包/类
@Test ()
public void appendCSVToDatabase() throws FileNotFoundException {
	loginBasicUser();

	WebClient client = getClient(false);
	client.type("multipart/form-data");
	
	Attachment att = createAttachmentFromFile("/mondial.accdb", "dataFile");
	client = getClient(false);
	client.type("multipart/form-data");
	Response response = client.path("/"+logicalDatabaseId+"/data/test").post(new MultipartBody(att));
	assertEquals(201, response.getStatus());

	String id = getIdFromResponse(response);
	DatabaseReference r = new DatabaseReference(Integer.parseInt(id), false);
	AbstractResourceTest.databases.add(r);

	// try adding a csv
	client = getClient(false);
	client.type("multipart/form-data");
	
	att = createAttachmentFromFile("/small_test.csv", "dataFile");
	response = client.path("/"+id+"/import/testTable/test").post(new MultipartBody(att));
	assertEquals(201, response.getStatus());
	
	String actualTableName = getIdFromResponse(response);
	System.out.println("New table name \"testTable\" wrangled to: \""+actualTableName+"\"");
}
 
开发者ID:ox-it,项目名称:ords-database-api,代码行数:29,代码来源:DatabaseTest.java


示例19: uploadSmallMalformedCSVFile

import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入依赖的package包/类
@Test ()
public void uploadSmallMalformedCSVFile() throws Exception {
	loginBasicUser();
	
	WebClient client = getClient(false);
	client.type("multipart/form-data");
	
	Attachment att = createAttachmentFromFile("/malformed_test.csv", "dataFile");

	Response response = client.path("/"+logicalDatabaseId+"/data/test").post(new MultipartBody(att));
	assertEquals(500, response.getStatus());
	
	logout();
}
 
开发者ID:ox-it,项目名称:ords-database-api,代码行数:15,代码来源:DatabaseTest.java


示例20: uploadLargeFileWithBasicAccount

import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入依赖的package包/类
@Test
public void uploadLargeFileWithBasicAccount() throws Exception {
	loginBasicUser();

	WebClient client = getClient(false);
	client.type("multipart/form-data");

	Attachment att = createAttachmentFromFile("/databases/professions.accdb", "dataFile");
	
	Response response = client.path("/"+logicalDatabaseId+"/data/test").post(new MultipartBody(att));
	assertEquals(403, response.getStatus());
	logout();
}
 
开发者ID:ox-it,项目名称:ords-database-api,代码行数:14,代码来源:DatabaseTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java XSD类代码示例发布时间:2022-05-21
下一篇:
Java IElementTagStructureHandler类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap