本文整理汇总了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);
}
示例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"));
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
示例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();
}
示例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();
}
示例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
);
}
示例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);
}
示例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\"}";
}
示例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\"}";
}
示例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);
}
}
示例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);
}
示例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);
}