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


Java FormDataContentDisposition类代码示例

本文整理汇总了Java中com.sun.jersey.core.header.FormDataContentDisposition的典型用法代码示例。如果您正苦于以下问题:Java FormDataContentDisposition类的具体用法?Java FormDataContentDisposition怎么用?Java FormDataContentDisposition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FormDataContentDisposition类属于com.sun.jersey.core.header包,在下文中一共展示了FormDataContentDisposition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: upload

import com.sun.jersey.core.header.FormDataContentDisposition; //导入依赖的package包/类
public void upload(String fileName, String sourceId,
		String fileTypeId, InputStream inputStream)
		throws ClientException {
	String path = UriBuilder
			.fromPath("/api/protected/file/upload/")
			.segment(sourceId)
			.segment(fileTypeId)
			.build().toString();
	FormDataMultiPart part = new FormDataMultiPart();
       part.bodyPart(
               new FormDataBodyPart(
                       FormDataContentDisposition
                               .name("file")
                               .fileName(fileName)
                               .build(),
                       inputStream, MediaType.APPLICATION_OCTET_STREAM_TYPE));
	doPostMultipart(path, part);
}
 
开发者ID:eurekaclinical,项目名称:eureka,代码行数:19,代码来源:EtlClient.java

示例2: doUploadFile

import com.sun.jersey.core.header.FormDataContentDisposition; //导入依赖的package包/类
ClientResponse.Status doUploadFile(WebResource webResource, File file, String sourceId, String fileTypeId) throws ClientHandlerException, UniformInterfaceException, IOException {
	try (InputStream is = new FileInputStream(file)) {
		FormDataMultiPart part = 
				new FormDataMultiPart();
		part.bodyPart(
				new FormDataBodyPart(
						FormDataContentDisposition
								.name("file")
								.fileName(file.getName())
								.build(), 
						is, MediaType.APPLICATION_OCTET_STREAM_TYPE));
		ClientResponse response = webResource
				.path("/api/protected/file/upload/" + sourceId + "/" + fileTypeId)
				.type(MediaType.MULTIPART_FORM_DATA_TYPE)
				.post(ClientResponse.class, part);
		ClientResponse.Status result = response.getClientResponseStatus();
		return result;
	}
}
 
开发者ID:eurekaclinical,项目名称:eureka,代码行数:20,代码来源:FileUploadSupport.java

示例3: attemptPublish

import com.sun.jersey.core.header.FormDataContentDisposition; //导入依赖的package包/类
private ClientResponse attemptPublish(File fileIS, String repositoryPath, boolean overwrite) throws FileNotFoundException {
    InputStream in = new FileInputStream(fileIS);
    String DEFAULT_PUBLISH_URL = biServerConnection.getUrl() + REPO_FILES_PUBLISH; //$NON-NLS-1$
    WebResource resource = client.resource(DEFAULT_PUBLISH_URL);
    
    FormDataMultiPart part = new FormDataMultiPart();
    part.field("importPath", repositoryPath + "/" + fileIS.getName(), MediaType.MULTIPART_FORM_DATA_TYPE)
        .field("fileUpload", in, MediaType.MULTIPART_FORM_DATA_TYPE)
        .field("overwriteFile", String.valueOf(overwrite), MediaType.MULTIPART_FORM_DATA_TYPE);

    part.getField("fileUpload").setContentDisposition(
        FormDataContentDisposition.name("fileUpload")
        .fileName(fileIS.getName()).build());

    Builder builder = resource
        .type(MediaType.MULTIPART_FORM_DATA)
        .accept(MediaType.TEXT_PLAIN);
    return builder.post(ClientResponse.class, part);
}
 
开发者ID:pentaho,项目名称:pdi-agile-bi-plugin,代码行数:20,代码来源:ModelServerPublish.java

示例4: publishMetaDataFile

import com.sun.jersey.core.header.FormDataContentDisposition; //导入依赖的package包/类
/**
 * Jersey call to use the put service to load a metadataFile file into the Jcr repsoitory
 * @param metadataFile
 * @param domainId is fileName
 * @throws Exception
 * return code to detrmine next step
 */
public int publishMetaDataFile(InputStream metadataFile, String domainId) throws Exception {
  String storeDomainUrl = biServerConnection.getUrl() + "plugin/data-access/api/metadata/import";
  WebResource resource = client.resource(storeDomainUrl);

  int response = ModelServerPublish.PUBLISH_FAILED;
  FormDataMultiPart part = new FormDataMultiPart();
  part.field("domainId", domainId, MediaType.MULTIPART_FORM_DATA_TYPE)
    .field("metadataFile", metadataFile, MediaType.MULTIPART_FORM_DATA_TYPE);
  part.getField("metadataFile").setContentDisposition(
      FormDataContentDisposition.name("metadataFile")
      .fileName(domainId).build());
  try {
    ClientResponse resp = resource
        .type(MediaType.MULTIPART_FORM_DATA_TYPE)
        .put(ClientResponse.class, part);
    if(resp != null && resp.getStatus() == 200){
      response = ModelServerPublish.PUBLISH_SUCCESS;
    }
  } catch (Exception ex) {
    Log.error(ex.getMessage());      
  }
  return response;
}
 
开发者ID:pentaho,项目名称:pdi-agile-bi-plugin,代码行数:31,代码来源:ModelServerPublish.java

示例5: testCreateCorrectParamCreationPb

import com.sun.jersey.core.header.FormDataContentDisposition; //导入依赖的package包/类
@Test
public void testCreateCorrectParamCreationPb() {
	StickyPolicy sPolicy = PolicyGenerator.buildStickyPolicy();
	final String owner = ""+1;
	
	FormDataContentDisposition fileDetail = FormDataContentDisposition.name("file").fileName("test.jpg").build();
	InputStream uploadedInputStream = null;
	try {
		uploadedInputStream = new FileInputStream(new File(FILE_DIR + FILE_NAME));
	} catch (FileNotFoundException e) {
		e.printStackTrace();
		fail();
	}
	
	when(mPiiService.create("test.jpg", uploadedInputStream, sPolicy, owner)).thenReturn(null);
	
	Response response = piiController.createPiiFile(uploadedInputStream, fileDetail, sPolicy, owner);
	
	verify(mPiiService).create("test.jpg", uploadedInputStream, sPolicy, owner);
	verifyZeroInteractions(mPuidDao);
	assertEquals(500, response.getStatus());
	
	Object entity = response.getEntity();
	assertNull(entity);
}
 
开发者ID:fdicerbo,项目名称:fiware-ppl,代码行数:26,代码来源:PiiControllerTest.java

示例6: addFile

import com.sun.jersey.core.header.FormDataContentDisposition; //导入依赖的package包/类
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces({ MediaType.APPLICATION_JSON })
public FileOutVO addFile(@FormDataParam("json") FormDataBodyPart json,
		@FormDataParam("data") FormDataBodyPart content,
		@FormDataParam("data") FormDataContentDisposition contentDisposition,
		@FormDataParam("data") final InputStream input) throws AuthenticationException, AuthorisationException, ServiceException {
	// in.setTrialId(trialId);
	// in.setModule(FileModule.TRIAL_DOCUMENT);
	// https://stackoverflow.com/questions/27609569/file-upload-along-with-other-object-in-jersey-restful-web-service
	json.setMediaType(MediaType.APPLICATION_JSON_TYPE);
	FileInVO in = json.getValueAs(FileInVO.class);
	FileStreamInVO stream = new FileStreamInVO();
	stream.setStream(input);
	stream.setMimeType(content.getMediaType().toString()); // .getType());
	stream.setSize(contentDisposition.getSize());
	stream.setFileName(contentDisposition.getFileName());
	return WebUtil.getServiceLocator().getFileService().addFile(auth, in, stream);
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:20,代码来源:FileResource.java

示例7: updateFile

import com.sun.jersey.core.header.FormDataContentDisposition; //导入依赖的package包/类
@PUT
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces({ MediaType.APPLICATION_JSON })
public FileOutVO updateFile(@FormDataParam("json") FormDataBodyPart json,
		@FormDataParam("data") FormDataBodyPart content,
		@FormDataParam("data") FormDataContentDisposition contentDisposition,
		@FormDataParam("data") final InputStream input) throws AuthenticationException, AuthorisationException, ServiceException {
	// in.setId(fileId);
	json.setMediaType(MediaType.APPLICATION_JSON_TYPE);
	FileInVO in = json.getValueAs(FileInVO.class);
	FileStreamInVO stream = new FileStreamInVO();
	stream.setStream(input);
	stream.setMimeType(content.getMediaType().toString()); // .getType());
	stream.setSize(contentDisposition.getSize());
	stream.setFileName(contentDisposition.getFileName());
	return WebUtil.getServiceLocator().getFileService().updateFile(auth, in, stream);
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:18,代码来源:FileResource.java

示例8: updateInputField

import com.sun.jersey.core.header.FormDataContentDisposition; //导入依赖的package包/类
@PUT
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces({ MediaType.APPLICATION_JSON })
public InputFieldOutVO updateInputField(@FormDataParam("json") InputFieldInVO in,
		@FormDataParam("data") FormDataBodyPart content,
		@FormDataParam("data") FormDataContentDisposition contentDisposition,
		@FormDataParam("data") final InputStream input) throws Exception {
	in.setDatas(CommonUtil.inputStreamToByteArray(input));
	in.setMimeType(content.getMediaType().toString());
	in.setFileName(contentDisposition.getFileName());
	return WebUtil.getServiceLocator().getInputFieldService().updateInputField(auth, in);
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:13,代码来源:InputFieldResource.java

示例9: stream2File

import com.sun.jersey.core.header.FormDataContentDisposition; //导入依赖的package包/类
public boolean stream2File(InputStream uploadedInputStream, FormDataContentDisposition fileDetail) {
    String filePath = this.resolvePath(fileDetail);
    this.deleteIf(filePath);

    byte[] bytes = new byte[1024];
    OutputStream out;
    int read;
    try {
        out = new FileOutputStream(new File(filePath));
        while ((read = uploadedInputStream.read(bytes)) != -1) {
            out.write(bytes, 0, read);
        }
        out.flush();
        out.close();
    } catch (IOException e) {
        LOG.error("Filed to write the stream to file. Cause: {}", e.getMessage());
        return false;
    }
    return true;
}
 
开发者ID:oxaoo,项目名称:mingi,代码行数:21,代码来源:FileWriter.java

示例10: uploadFile

import com.sun.jersey.core.header.FormDataContentDisposition; //导入依赖的package包/类
/**
    * Returns text response to caller containing current time-stamp
    * @return error response in case of missing parameters an internal exception or
    * success response if file has been stored successfully 
    */
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
   public Response uploadFile(
       @FormDataParam("file") InputStream uploadedInputStream,
       @FormDataParam("file") FormDataContentDisposition fileDetail) {
	
	// check if all form parameters are provided
	if (uploadedInputStream == null || fileDetail == null)
		return Response.status(400).entity("Invalid form data").build();
	
	// create our destination folder, if it not exists
	try {
		createFolderIfNotExists(UPLOAD_FOLDER);
	} catch (SecurityException se) {
		return Response.status(500).entity("Can not create destination folder on server").build();
	}

       String uploadedFileLocation = UPLOAD_FOLDER + fileDetail.getFileName();
       try {
		saveToFile(uploadedInputStream, uploadedFileLocation);
	} catch (IOException e) {
		return Response.status(500).entity("Can not save file").build();
	}

       return Response.status(200).entity("File saved to " + uploadedFileLocation).build();
   }
 
开发者ID:JavaTutorialNetwork,项目名称:Tutorials,代码行数:32,代码来源:FileUploadService.java

示例11: post

import com.sun.jersey.core.header.FormDataContentDisposition; //导入依赖的package包/类
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response post(
		@FormDataParam("file") InputStream file,
		@FormDataParam("file") FormDataContentDisposition fileDetail,
		@FormDataParam("file") FormDataBodyPart bodyPart,
		@FormDataParam("path") String path,
		@FormDataParam("draft") @DefaultValue("false") Boolean draft,
		@FormDataParam("overwrite") @DefaultValue("true") Boolean overwrite
		) throws Exception {
		
		Metadata fMeta = new Metadata();
		fMeta.setMimeType(bodyPart.getMediaType().toString());
		fMeta.setIsDir(false);
		fMeta.setName(fileDetail.getFileName());
		fMeta.setPath(path);

		fMeta = fileService.upload(file,fMeta,draft,overwrite);
		
		return Response.ok(fMeta).build();
	
}
 
开发者ID:josecoelho,项目名称:yep-rest-file-server,代码行数:23,代码来源:FilesRest.java

示例12: storeFile

import com.sun.jersey.core.header.FormDataContentDisposition; //导入依赖的package包/类
@POST
@Path("/kvstore")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
   @ResourceFilters(StaashAuditFilter.class)
public String storeFile(
		@FormDataParam("value") InputStream uploadedInputStream,
		@FormDataParam("value") FormDataContentDisposition fileDetail) {
	try {
		writeToChunkedKVStore(uploadedInputStream, fileDetail.getFileName());
	} catch (IOException e) {
		e.printStackTrace();
		return "{\"msg\":\"file could not be uploaded\"}";
	}
	return "{\"msg\":\"file successfully uploaded\"}";
}
 
开发者ID:Netflix,项目名称:staash,代码行数:17,代码来源:StaashDataResourceImpl.java

示例13: testUpdateIncorrectParam

import com.sun.jersey.core.header.FormDataContentDisposition; //导入依赖的package包/类
@Test
public void testUpdateIncorrectParam() {
	final String owner = ""+1;
	final Long piiUniqueId = (long) 12345789;
	
	FormDataContentDisposition fileDetail = FormDataContentDisposition.name("file").fileName("newFile.jpg").build();
	
	Response response = piiController.updateFile(piiUniqueId.toString(), null, fileDetail, null, owner);
	
	verifyZeroInteractions(mPiiService);
	verifyZeroInteractions(mPuidDao);
	assertEquals(400, response.getStatus());
	
	Object entity = response.getEntity();
	assertNull(entity);
}
 
开发者ID:fdicerbo,项目名称:fiware-ppl,代码行数:17,代码来源:PiiControllerTest.java

示例14: setProbandImage

import com.sun.jersey.core.header.FormDataContentDisposition; //导入依赖的package包/类
@PUT
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces({ MediaType.APPLICATION_JSON })
public ProbandImageOutVO setProbandImage(@FormDataParam("json") ProbandImageInVO in,
		@FormDataParam("data") FormDataBodyPart content,
		@FormDataParam("data") FormDataContentDisposition contentDisposition,
		@FormDataParam("data") final InputStream input) throws Exception {
	in.setDatas(CommonUtil.inputStreamToByteArray(input));
	in.setMimeType(content.getMediaType().toString());
	in.setFileName(contentDisposition.getFileName());
	return WebUtil.getServiceLocator().getProbandService().setProbandImage(auth, in);
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:13,代码来源:ProbandResource.java

示例15: setStaffImage

import com.sun.jersey.core.header.FormDataContentDisposition; //导入依赖的package包/类
@PUT
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces({ MediaType.APPLICATION_JSON })
public StaffImageOutVO setStaffImage(@FormDataParam("json") StaffImageInVO in,
		@FormDataParam("data") FormDataBodyPart content,
		@FormDataParam("data") FormDataContentDisposition contentDisposition,
		@FormDataParam("data") final InputStream input) throws Exception {
	in.setDatas(CommonUtil.inputStreamToByteArray(input));
	in.setMimeType(content.getMediaType().toString());
	in.setFileName(contentDisposition.getFileName());
	return WebUtil.getServiceLocator().getStaffService().setStaffImage(auth, in);
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:13,代码来源:StaffResource.java


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