本文整理汇总了Java中com.sun.jersey.multipart.FormDataBodyPart.getFormDataContentDisposition方法的典型用法代码示例。如果您正苦于以下问题:Java FormDataBodyPart.getFormDataContentDisposition方法的具体用法?Java FormDataBodyPart.getFormDataContentDisposition怎么用?Java FormDataBodyPart.getFormDataContentDisposition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.jersey.multipart.FormDataBodyPart
的用法示例。
在下文中一共展示了FormDataBodyPart.getFormDataContentDisposition方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newGift
import com.sun.jersey.multipart.FormDataBodyPart; //导入方法依赖的package包/类
@POST
@Path("{id}/gifts")
@Consumes({ MediaType.MULTIPART_FORM_DATA })
public Response newGift(@PathParam("id") Id id, @FormDataParam("file") InputStream uploadedInputStream,
@FormDataParam("file") FormDataBodyPart formDataBodyPart) {
ActionGift gift = null;
if (id != null) {
// Get product and image.
FormDataContentDisposition fileDetails = formDataBodyPart.getFormDataContentDisposition();
MediaAsset newMediaAsset = mediaAssetService.create(uploadedInputStream, fileDetails.getFileName());
gift = app.model(ActionGift.class);
gift.setMediaAsset(newMediaAsset);
gift.setPosition(99);
gift.setId(app.nextId());
saveGift(gift, id);
} else {
throwBadRequest("SlideShowId cannot be null in requestURI. Expecting: slide-shows/{id}/slides");
}
if (gift == null || gift.getId() == null) {
throwInternalServerError();
}
return ok(gift);
}
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:29,代码来源:DiscountPromotionResource.java
示例2: newSlide
import com.sun.jersey.multipart.FormDataBodyPart; //导入方法依赖的package包/类
@POST
@Path("{id}/slides")
@Consumes({MediaType.MULTIPART_FORM_DATA})
public Response newSlide(@PathParam("id") Id id, @FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataBodyPart formDataBodyPart) {
Slide slide = null;
if (id != null) {
// Get product and image.
FormDataContentDisposition fileDetails = formDataBodyPart.getFormDataContentDisposition();
MediaAsset newMediaAsset = mediaAssetService.create(uploadedInputStream, fileDetails.getFileName());
MediaAssetDirectory directory = mediaAssetDirectoryService.createOrGetSystem(SYSTEM_PATH);
if (directory != null) {
newMediaAsset.setDirectoryId(directory.getId());
mediaAssets.update(newMediaAsset);
}
slide = App.get().model(Slide.class);
slide.setMediaAsset(newMediaAsset);
slide.setPosition(99);
slide.setId(App.get().nextId());
saveSlide(slide, id);
} else {
throwBadRequest("SlideShowId cannot be null in requestURI. Expecting: slide-shows/{id}/slides");
}
if (slide == null || slide.getId() == null) {
throwInternalServerError();
}
return ok(slide);
}
示例3: newFile
import com.sun.jersey.multipart.FormDataBodyPart; //导入方法依赖的package包/类
@POST
@Path("{id}/slides/{slideId}/files")
@Consumes({ MediaType.MULTIPART_FORM_DATA })
public Response newFile(@PathParam("id") Id id, @PathParam("slideId") Id slideId,
@FormDataParam("file") InputStream uploadedInputStream,
@FormDataParam("file") FormDataBodyPart formDataBodyPart) {
Slide slide = null;
if (id != null && slideId != null) {
// Get product and image.
WebSlideShow slideShow = checked(service.get(WebSlideShow.class, id));
slide = slideShow.getSlides().stream().filter(item -> item.getId().equals(slideId)).findFirst().get();
FormDataContentDisposition fileDetails = formDataBodyPart.getFormDataContentDisposition();
MediaAsset newMediaAsset = mediaAssetService.create(uploadedInputStream, fileDetails.getFileName());
slide.setLinkedMediaAsset(newMediaAsset);
slide.setLink(null);
service.update(slideShow);
} else {
throwBadRequest(
"SlideShowId and slideId cannot be null in requestURI. Expecting: slide-shows/{id}/slides/{slideId}/files");
}
if (slide == null || slide.getId() == null) {
throwInternalServerError();
}
return ok(slide);
}
示例4: createFile
import com.sun.jersey.multipart.FormDataBodyPart; //导入方法依赖的package包/类
@POST
@Path("{id}/file")
@Consumes({ MediaType.MULTIPART_FORM_DATA })
public Response createFile(@PathParam("id") Id id, @FormDataParam("file") InputStream uploadedInputStream,
@FormDataParam("file") FormDataBodyPart formDataBodyPart) {
// Get product and image.
FormDataContentDisposition fileDetails = formDataBodyPart.getFormDataContentDisposition();
MediaAsset newMediaAsset = mediaAssetService.create(uploadedInputStream, fileDetails.getFileName());
// VacancyGroup vacancyGroup = service.get(VacancyGroup.class, id);
// vacancyGroup.setImage(newMediaAsset);
// service.update(vacancyGroup);
return ok(newMediaAsset);
}
示例5: createImage
import com.sun.jersey.multipart.FormDataBodyPart; //导入方法依赖的package包/类
@POST
@Path("image")
@Consumes({ MediaType.MULTIPART_FORM_DATA })
public Response createImage(@PathParam("id") Id id, @FormDataParam("file") InputStream uploadedInputStream,
@FormDataParam("file") FormDataBodyPart formDataBodyPart) {
// Get product and image.
FormDataContentDisposition fileDetails = formDataBodyPart.getFormDataContentDisposition();
MediaAsset newMediaAsset = mediaAssetService.create(uploadedInputStream, fileDetails.getFileName());
// VacancyGroup vacancyGroup = service.get(VacancyGroup.class, id);
// vacancyGroup.setImage(newMediaAsset);
// service.update(vacancyGroup);
return ok(newMediaAsset);
}
示例6: createMediaAsset
import com.sun.jersey.multipart.FormDataBodyPart; //导入方法依赖的package包/类
@POST
@Path("{id}")
@Consumes({ MediaType.MULTIPART_FORM_DATA })
public Response createMediaAsset(@FormDataParam("file") InputStream uploadedInputStream,
@FormDataParam("file") FormDataBodyPart formDataBodyPart, @PathParam("id") Id id) {
// Get product and image.
FormDataContentDisposition fileDetails = formDataBodyPart.getFormDataContentDisposition();
MediaAsset newMediaAsset = mediaAssetService.create(uploadedInputStream, fileDetails.getFileName());
newMediaAsset.setDirectoryId(id);
mediaAssets.update(newMediaAsset);
return ok(newMediaAsset);
}
示例7: createSystemMediaAsset
import com.sun.jersey.multipart.FormDataBodyPart; //导入方法依赖的package包/类
@POST
@Path("/system")
@Consumes({ MediaType.MULTIPART_FORM_DATA })
public Response createSystemMediaAsset(@FormDataParam("file") InputStream uploadedInputStream,
@FormDataParam("file") FormDataBodyPart formDataBodyPart, @QueryParam("path") String path) {
FormDataContentDisposition fileDetails = formDataBodyPart.getFormDataContentDisposition();
MediaAssetDirectory directory = mediaAssetDirectoryService.createOrGetSystem(path);
if (directory != null) {
MediaAsset newMediaAsset = mediaAssetService.create(uploadedInputStream, fileDetails.getFileName());
newMediaAsset.setDirectoryId(directory.getId());
mediaAssets.update(newMediaAsset);
return ok(newMediaAsset);
}
return notFound();
}
示例8: updateContentMediaAsset
import com.sun.jersey.multipart.FormDataBodyPart; //导入方法依赖的package包/类
@POST
@Path("/update-file/{id}")
@Consumes({ MediaType.MULTIPART_FORM_DATA })
public Response updateContentMediaAsset(@FormDataParam("file") InputStream uploadedInputStream,
@FormDataParam("file") FormDataBodyPart formDataBodyPart, @PathParam("id") Id id) {
// Get product and image.
FormDataContentDisposition fileDetails = formDataBodyPart.getFormDataContentDisposition();
MediaAsset newMediaAsset = mediaAssetService.update(id, uploadedInputStream, fileDetails.getFileName());
return ok(newMediaAsset);
}
示例9: newMediaAssetPreviewImage
import com.sun.jersey.multipart.FormDataBodyPart; //导入方法依赖的package包/类
@PUT
@Path("{id}/media-assets/{mediaAssetId}/preview-image")
@Consumes({ MediaType.MULTIPART_FORM_DATA })
public Response newMediaAssetPreviewImage(@PathParam("id") Id id, @PathParam("mediaAssetId") Id mediaAssetId,
@FormDataParam("file") InputStream uploadedInputStream,
@FormDataParam("file") FormDataBodyPart formDataBodyPart) {
CatalogMediaAsset mediaAsset = null;
if (id != null && mediaAssetId != null) {
// Get product and media-asset.
Product product = checked(service.get(Product.class, id));
mediaAsset = checked(service.get(CatalogMediaAsset.class, mediaAssetId));
// Just make sure that the objects match.
if (product.getId().equals(mediaAsset.getProductId())) {
FormDataContentDisposition fileDetails = formDataBodyPart.getFormDataContentDisposition();
String videoSysPath = mediaAsset.getSystemPath();
if (videoSysPath != null) {
String absSystemPath = videoSysPath.substring(0, videoSysPath.lastIndexOf(File.separatorChar) + 1)
+ fileDetails.getFileName();
File savedFile = catalogMediaHelper.saveToDisk(uploadedInputStream, absSystemPath, product);
// We need to get the relative path from the saved file in
// case a version number has been added.
String relativePath = catalogMediaHelper.toRelativeAssetPath(savedFile.getAbsolutePath());
mediaAsset.setPreviewImagePath(catalogMediaHelper.toWebURI(relativePath));
service.update(mediaAsset);
}
}
} else {
throwBadRequest(
"ProductId and mediaAssetId cannot be null in requestURI. Expecting: products/{id}/media-assets/{mediaAssetId}/preview-image");
}
if (mediaAsset == null || mediaAsset.getId() == null) {
throwInternalServerError();
}
return ok(mediaAsset);
}