當前位置: 首頁>>代碼示例>>Java>>正文


Java FormDataParam類代碼示例

本文整理匯總了Java中com.sun.jersey.multipart.FormDataParam的典型用法代碼示例。如果您正苦於以下問題:Java FormDataParam類的具體用法?Java FormDataParam怎麽用?Java FormDataParam使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FormDataParam類屬於com.sun.jersey.multipart包,在下文中一共展示了FormDataParam類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getLabelSVGByFile

import com.sun.jersey.multipart.FormDataParam; //導入依賴的package包/類
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MEDIA_TYPE)
@ApiOperation(value = "Returns a GEO label", notes = "Requires metadata/feedback documents as data stream")
@ApiResponses({@ApiResponse(code = 400, message = "Error in feedback/metadata document")})
public Response getLabelSVGByFile(
/* @ApiParam("LML representation") */@FormDataParam(Constants.PARAM_LML)
Label label,
/* @ApiParam("Metadata document") */@FormDataParam(Constants.PARAM_METADATA)
InputStream metadataInputStream,
/* @ApiParam("Feedback document") */@FormDataParam(Constants.PARAM_FEEDBACK)
InputStream feedbackInputStream,
/* @ApiParam("Desired size of returned PNG") */@FormDataParam(Constants.PARAM_SIZE)
Integer size) throws IOException {
    Label l = label;
    if (l == null)
        l = this.lmlResource.get().getLabelByStream(metadataInputStream, feedbackInputStream);
    return createLabelPNGResponse(size != null ? size.intValue() : DEFAULT_PNG_SIZE, l);
}
 
開發者ID:52North,項目名稱:GEO-label-java,代碼行數:20,代碼來源:PNGResourceV1.java

示例2: annotate_POST_MULTIPART

import com.sun.jersey.multipart.FormDataParam; //導入依賴的package包/類
@POST
@Path("/plans/{plan}/{sync:sync|async}")
@Consumes({ MediaType.MULTIPART_FORM_DATA })
public Response annotate_POST_MULTIPART(
		@Context ServletContext servletContext,
		@Context HttpContext httpContext,
		@PathParam("plan") String planName,
		@PathParam("sync") String sync,
		@FormDataParam("text") @DefaultValue("") String text,
		@FormDataParam("sourcedb") @DefaultValue("") String sourcedb,
		@FormDataParam("sourceid") @DefaultValue("") String sourceid,
		FormDataMultiPart formData
		) throws Exception {
	return annotate(servletContext, httpContext, planName, text, sourcedb, sourceid, null, formData, sync.equals("async"));
}
 
開發者ID:Bibliome,項目名稱:alvisnlp,代碼行數:16,代碼來源:PubAnnotation.java

示例3: addFile

import com.sun.jersey.multipart.FormDataParam; //導入依賴的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

示例4: updateFile

import com.sun.jersey.multipart.FormDataParam; //導入依賴的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

示例5: updateInputField

import com.sun.jersey.multipart.FormDataParam; //導入依賴的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

示例6: uploadFile

import com.sun.jersey.multipart.FormDataParam; //導入依賴的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

示例7: uploadImage

import com.sun.jersey.multipart.FormDataParam; //導入依賴的package包/類
@POST
@Path("/{id}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@ApiOperation(value = "Upload Image", notes = "Uploads image according to its type and id and saves it in server", response = ServerResponse.class)
@ApiResponses({ @ApiResponse(code = 400, message = "User Exists with username"),
		@ApiResponse(code = 201, message = "CREATED") })
public Response uploadImage(@Context HttpServletRequest hh, 
		@ApiParam(value = "UserId/AppKey ", required = true) @PathParam("id") String id,
		@ApiParam(value = "type = user/app", required = true) @QueryParam("type") String type,
		@ApiParam(value = "image file", required = true) @FormDataParam("image") InputStream imageInputStream) {

	if (id == null || type == null || (!type.equalsIgnoreCase(APP_IMAGE_TYPE) && !type.equalsIgnoreCase(USER_IMAGE_TYPE)) || imageInputStream == null)
		return Response.status(Status.BAD_REQUEST).entity(new ResponseMessage("userId, type=app/user, image is mandatory!")).build();

	if(type.equalsIgnoreCase(USER_IMAGE_TYPE)) {
		User user = RepositoryFactory.getInstance().getUserRepository().findByIdAndIsDeleted(id, false);
		if (user == null)
			return Response.status(Status.BAD_REQUEST).entity(new ResponseMessage("user doesnt exist with given id")).build();
		user.imageUrl = new StorageProvider().uploadImageFile(imageInputStream, user.organisationId, user.id, type);
		RepositoryFactory.getInstance().getUserRepository().save(user);
	}
	
	return Response.status(Status.CREATED).entity(new ResponseMessage("image uploaded!")).build();
}
 
開發者ID:generaldevelopers,項目名稱:bedrock,代碼行數:25,代碼來源:BaseImageService.java

示例8: post

import com.sun.jersey.multipart.FormDataParam; //導入依賴的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

示例9: upload

import com.sun.jersey.multipart.FormDataParam; //導入依賴的package包/類
/**
 * Upload a photo.
 * @param photo Photo to upload
 * @throws IOException If fails
 */
@POST
@Path("/upload")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public void upload(@FormDataParam("photo") final InputStream photo)
    throws IOException {
    final BufferedImage image = ImageIO.read(photo);
    final Image thumb = image.getScaledInstance(
        Tv.FOUR * Tv.HUNDRED, -1, Image.SCALE_SMOOTH
    );
    final BufferedImage nice = new BufferedImage(
        thumb.getWidth(null), thumb.getHeight(null),
        BufferedImage.TYPE_INT_RGB
    );
    nice.getGraphics().drawImage(thumb, 0, 0, null);
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ImageIO.write(nice, "png", baos);
    new SafeHuman(this.human(), this).profile().photo(baos.toByteArray());
    throw this.flash().redirect(
        this.uriInfo().getBaseUri(),
        "photo updated, thanks",
        Level.INFO
    );
}
 
開發者ID:aintshy,項目名稱:hub,代碼行數:29,代碼來源:ProfileRs.java

示例10: getLabelSVGByFile

import com.sun.jersey.multipart.FormDataParam; //導入依賴的package包/類
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces("image/svg+xml")
@ApiOperation(value = "Returns a GEO label", notes = "Requires metadata/feedback documents as data stream")
@ApiResponses({@ApiResponse(code = 400, message = "Error in feedback/metadata document")})
public Response getLabelSVGByFile(
/* @ApiParam("LML representation") */@FormDataParam(Constants.PARAM_LML)
Label label,
/* @ApiParam("Metadata document") */@FormDataParam(Constants.PARAM_METADATA)
InputStream metadataInputStream,
/* @ApiParam("Feedback document") */@FormDataParam(Constants.PARAM_FEEDBACK)
InputStream feedbackInputStream,
/* @ApiParam("Desired size of returned SVG") */@FormDataParam(Constants.PARAM_SIZE)
Integer size,
/* @ApiParam("Desired id of returned SVG root element") */@FormDataParam(Constants.PARAM_ID)
String id) throws IOException {
    Label l = label;
    if (l == null)
        l = this.lmlResource.get().getLabelByStream(metadataInputStream, feedbackInputStream);
    return createLabelSVGResponse(size != null ? size.intValue() : 200, id, l);
}
 
開發者ID:52North,項目名稱:GEO-label-java,代碼行數:22,代碼來源:SVGResourceV1.java

示例11: storeFile

import com.sun.jersey.multipart.FormDataParam; //導入依賴的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

示例12: storeNamedFile

import com.sun.jersey.multipart.FormDataParam; //導入依賴的package包/類
@POST
@Path("/kvstore/name/{name}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
   @ResourceFilters(StaashAuditFilter.class)
public String storeNamedFile(
		@FormDataParam("value") InputStream uploadedInputStream,
		@PathParam("name") String name) {
	try {
		writeToChunkedKVStore(uploadedInputStream, name);
	} catch (IOException e) {
		e.printStackTrace();
		return "{\"msg\":\"file could not be uploaded\"}";
	}
	return "{\"msg\":\"file successfully uploaded\"}";
}
 
開發者ID:Netflix,項目名稱:staash,代碼行數:17,代碼來源:StaashDataResourceImpl.java

示例13: insertArchive

import com.sun.jersey.multipart.FormDataParam; //導入依賴的package包/類
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
public void insertArchive(
        @FormDataParam("moduleSpec") ScriptModuleSpec moduleSpec,
        @FormDataParam("archiveJar") InputStream file) {
    validateModuleSpec(moduleSpec);
    String moduleId = moduleSpec.getModuleId().toString();
    try {
        java.nio.file.Path tempFile = Files.createTempFile(moduleId, ".jar");
        Files.copy(file, tempFile, StandardCopyOption.REPLACE_EXISTING);
        JarScriptArchive jarScriptArchive = new JarScriptArchive.Builder(tempFile)
            .setModuleSpec(moduleSpec)
            .build();
        repository.insertArchive(jarScriptArchive);
    } catch (IOException e) {
        throw new WebApplicationException(e);
    }
}
 
開發者ID:Netflix,項目名稱:Nicobar,代碼行數:19,代碼來源:ArchiveRepositoryResource.java

示例14: setProbandImage

import com.sun.jersey.multipart.FormDataParam; //導入依賴的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.multipart.FormDataParam; //導入依賴的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.multipart.FormDataParam類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。