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


Java MultipartBody类代码示例

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


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


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