本文整理汇总了Java中javax.ws.rs.core.MediaType.MULTIPART_FORM_DATA属性的典型用法代码示例。如果您正苦于以下问题:Java MediaType.MULTIPART_FORM_DATA属性的具体用法?Java MediaType.MULTIPART_FORM_DATA怎么用?Java MediaType.MULTIPART_FORM_DATA使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.ws.rs.core.MediaType
的用法示例。
在下文中一共展示了MediaType.MULTIPART_FORM_DATA属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updatePaymentFileConfirm
@PUT
@Path("/{id}/payments/{referenceUid}/confirm")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "upload PaymentFile")
@ApiResponses(value = {
@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns"),
@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })
public Response updatePaymentFileConfirm(@Context HttpServletRequest request, @Context HttpHeaders header,
@Context Company company, @Context Locale locale, @Context User user,
@Context ServiceContext serviceContext,
@ApiParam(value = "id of payments", required = true) @PathParam("id") String id,
@ApiParam(value = "reference of paymentFile", required = true) @PathParam("referenceUid") String referenceUid,
@ApiParam(value = "Attachment files") @Multipart("file") Attachment file,
@ApiParam(value = "Metadata of PaymentFile") @Multipart("confirmNote") String confirmNote,
@ApiParam(value = "Metadata of PaymentFile") @Multipart("paymentMethod") String paymentMethod,
@ApiParam(value = "Metadata of PaymentFile") @Multipart("confirmPayload") String confirmPayload);
示例2: info
@POST
@Path("/info")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.MULTIPART_FORM_DATA)
@ApiOperation("Provides a summary of the connector as it would be built using a ConnectorTemplate identified by the provided `connector-template-id` and the data given in `connectorSettings`")
public ConnectorSummary info(@MultipartForm final CustomConnectorFormData connectorFormData) {
try {
final String specification;
try (BufferedSource source = Okio.buffer(Okio.source(connectorFormData.getSpecification()))) {
specification = source.readUtf8();
}
final ConnectorSettings connectorSettings = new ConnectorSettings.Builder()
.createFrom(connectorFormData.getConnectorSettings())
.putConfiguredProperty("specification", specification)
.build();
return withGeneratorAndTemplate(connectorSettings.getConnectorTemplateId(),
(generator, template) -> generator.info(template, connectorSettings));
} catch (IOException e) {
throw SyndesisServerException.launderThrowable("Failed to read specification", e);
}
}
示例3: annotate_POST_MULTIPART
@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"));
}
示例4: addDossierFileByDossierId
@POST
@Path("/{id}/files")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "addDossierFileByDossierId)", response = DossierFileModel.class)
@ApiResponses(value = {
@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns the DossierFileModel was updated", response = DossierFileResultsModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })
public Response addDossierFileByDossierId(@Context HttpServletRequest request, @Context HttpHeaders header,
@Context Company company, @Context Locale locale, @Context User user,
@Context ServiceContext serviceContext,
@ApiParam(value = "Attachment files", required = true) @Multipart("file") Attachment file,
@ApiParam(value = "id of dossier", required = true) @PathParam("id") String id,
@ApiParam(value = "Metadata of DossierFile", required = true) @Multipart("referenceUid") String referenceUid,
@ApiParam(value = "Metadata of DossierFile") @Multipart("dossierTemplateNo") String dossierTemplateNo,
@ApiParam(value = "Metadata of DossierFile") @Multipart("dossierPartNo") String dossierPartNo,
@ApiParam(value = "Metadata of DossierFile") @Multipart("fileTemplateNo") String fileTemplateNo,
@ApiParam(value = "Metadata of DossierFile") @Multipart("displayName") String displayName,
@ApiParam(value = "Metadata of DossierFile") @Multipart("fileType") String fileType,
@ApiParam(value = "Metadata of DossierFile") @Multipart("isSync") String isSync,
@ApiParam(value = "Metadata of DossierFile") @Multipart("formData") @Nullable String formData);
示例5: receiveFile
@POST
@Path("{label}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public void receiveFile(MultipartInput input, @PathParam("label") String label) {
List<InputPart> parts = input.getParts();
parts.stream().filter(p -> p.getMediaType().getType().startsWith("image"))
.forEach(p -> this.saveImage(p, label));
input.close();
}
示例6: update
@PUT
@Path(value = "/{id}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public void update(@NotNull @PathParam("id") @ApiParam(required = true) String id, @MultipartForm ConnectorFormData connectorFormData) {
if (connectorFormData.getConnector() == null) {
throw new IllegalArgumentException("Missing connector parameter");
}
Connector connectorToUpdate = connectorFormData.getConnector();
if (connectorFormData.getIconInputStream() != null) {
try(BufferedInputStream iconStream = new BufferedInputStream(connectorFormData.getIconInputStream())) {
// URLConnection.guessContentTypeFromStream resets the stream after inspecting the media type so
// can continue to be used, rather than being consumed.
String guessedMediaType = URLConnection.guessContentTypeFromStream(iconStream);
if (!guessedMediaType.startsWith("image/")) {
throw new IllegalArgumentException("Invalid file contents for an image");
}
MediaType mediaType = MediaType.valueOf(guessedMediaType);
Icon.Builder iconBuilder = new Icon.Builder().mediaType(mediaType.toString());
Icon icon = getDataManager().create(iconBuilder.build());
iconDao.write(icon.getId().get(), iconStream);
connectorToUpdate = connectorToUpdate.builder().icon("db:" + icon.getId().get()).build();
} catch (IOException e) {
throw new IllegalArgumentException("Error while reading multipart request", e);
}
}
getDataManager().update(connectorToUpdate);
}
示例7: uploadOfficeSiteLogo
@PUT
@Path("/{id}/logo")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response uploadOfficeSiteLogo(@Context HttpServletRequest request, @Context HttpHeaders header,
@Context Company company, @Context Locale locale, @Context User user,
@Context ServiceContext serviceContext, @PathParam("id") long id,
@Multipart("file") Attachment attachment, @Multipart("fileName") String fileName,
@Multipart("fileType") String fileType, @Multipart("fileSize") long fileSize);
示例8: addInputField
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces({ MediaType.APPLICATION_JSON })
public InputFieldOutVO addInputField(@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().addInputField(auth, in);
}
示例9: setStaffImage
@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);
}
示例10: uploadCoreBackup
@POST
@Path("{serviceName}/getOfflinePendingChanges")
@Consumes({MediaType.MULTIPART_FORM_DATA})
@Produces({MediaType.APPLICATION_JSON})
public Response uploadCoreBackup(
@PathParam("serviceName") String serviceName,
@FormDataParam("file") InputStream zipByteArray,
@FormDataParam("file") FormDataContentDisposition fileDisposition) throws IOException, SerializerException {
return Response.ok(offlineModeService.calculateOfflinePendingChanges(serviceName, zipByteArray)).build();
}
示例11: uploadFile
@POST
@Path("upload_start/{path: .*}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
public File uploadFile(@PathParam("path") String path,
@FormDataParam("file") InputStream fileInputStream,
@FormDataParam("file") FormDataContentDisposition contentDispositionHeader,
@FormDataParam("fileName") FileName fileName,
@QueryParam("extension") String extension) throws Exception {
// add some validation
InputValidation inputValidation = new InputValidation();
inputValidation.validate(fileName);
List<String> pathList = PathUtils.toPathComponents(path);
pathList.add(SqlUtils.quoteIdentifier(fileName.getName()));
final FilePath filePath = FilePath.fromURLPath(homeName, PathUtils.toFSPathString(pathList));
final FileConfig config = new FileConfig();
try {
// upload file to staging area
final org.apache.hadoop.fs.Path stagingLocation = fileStore.stageFile(filePath, extension, fileInputStream);
config.setLocation(stagingLocation.toString());
config.setName(filePath.getLeaf().getName());
config.setCtime(System.currentTimeMillis());
config.setFullPathList(filePath.toPathList());
config.setOwner(securityContext.getUserPrincipal().getName());
config.setType(FileFormat.getFileFormatType(Collections.singletonList(extension)));
} catch (IOException ioe) {
throw new DACException("Error writing to file at " + filePath, ioe);
}
final File file = newFile(filePath.toUrlPath(),
filePath, FileFormat.getForFile(config), 0, 0, true, true, true,
DatasetType.PHYSICAL_DATASET_HOME_FILE
);
return file;
}
示例12: getMultipartPart
@POST
@Path("/multipart-part")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public static String getMultipartPart(
@FormParam("content") final Part content)
throws IOException {
return content.getSubmittedFileName();
}
示例13: addDossierLogByDossierId
@POST
@Path("log/{id}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "addDossierLogByDossierId)", response = DossierLogModel.class)
@ApiResponses(value = {
@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns the DossierLogModel was updated", response = DossierLogResultsModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })
public Response addDossierLogByDossierId(@Context HttpServletRequest request, @Context HttpHeaders header,
@Context Company company, @Context Locale locale, @Context User user,
@Context ServiceContext serviceContext,
@ApiParam(value = "id of dossier", required = true) @PathParam("id") long id,
@ApiParam(value = "NotificationType", required = true) @Multipart("notificationType") String notificationType,
@ApiParam(value = "Metadata of DossierLog") @Multipart("author") String author,
@ApiParam(value = "Metadata of DossierLog") @Multipart("payload") String payload,
@ApiParam(value = "Metadata of DossierLog") @Multipart("content") String content);
示例14: uploadPhoto
@PUT
@Path("/{id}/photo")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response uploadPhoto(@Context HttpServletRequest request, @Context HttpHeaders header,
@Context Company company, @Context Locale locale, @Context User user,
@Context ServiceContext serviceContext, @PathParam("id") long id, @Multipart("file") Attachment attachment,
@Multipart("fileName") String fileName, @Multipart("fileType") String fileType,
@Multipart("fileSize") long fileSize);
示例15: uploadDocument
/**
* Sends the documents to the Ariba and resumes the event. Also uploads the
* documents to ECM so that they could be downloaded by the user later.
*
* @param eventId
* @param body
* @return
*/
@POST
@Produces(MediaType.APPLICATION_JSON)
@Path(UPLOAD_DOCUMENT_API)
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response uploadDocument(@PathParam(PARAMETER_EVENT_ID) String eventId, MultipartBody body) {
logger.debug(DEBUG_UPLOADING_ATTACHMENT_DOCUMENTS_FOR_EVENT_WITH_EVENT_ID);
Response response = null;
IndiaLocalizationDestination indiaLocalizationDestination = new IndiaLocalizationDestination(
IndiaLocalizationDestination.NAME);
PartnerFlowExtensionApiFacade flowExtensionApiFacade = new PartnerFlowExtensionApiFacade(
indiaLocalizationDestination.getAribaOpenApisEnvironmentUrl(),
indiaLocalizationDestination.getFlowExtensionId(),
indiaLocalizationDestination.getServiceProviderUser(),
indiaLocalizationDestination.getServiceProviderPassword(), indiaLocalizationDestination.getApiKey());
Asn asn = asnDao.findByEvent(eventId);
if (asn == null) {
logger.debug(DEBUG_EVENT_WITH_EVENT_ID_WAS_NOT_FOUND);
response = Response.status(Response.Status.NOT_FOUND).build();
} else {
try {
// upload all attachments in the ECM repository
logger.debug(DEBUG_UPLOADING_DOCUMENTS_IN_ECM_FOR_EVENT_WITH_EVENT_ID, eventId);
List<AttachmentDocument> uploadedAttachments = documentDao.addAll(eventId, body.getAllAttachments());
// post documents to Ariba
logger.debug(DEBUG_RETRIEVING_DOCUMENTS_FROM_ECM);
Map<String, InputStream> documents = retrieveDocuments(uploadedAttachments);
logger.debug(DEBUG_POSTING_POCUMENTS_TO_ARIBA_FOR_EVENT_WITH_EVENT_ID, eventId);
flowExtensionApiFacade.postDocumentUpdate(eventId, documents);
// resume event
logger.debug(DEBUG_RESUMING_EVENT_WITH_EVENT_ID, eventId);
flowExtensionApiFacade.resumeEvent(eventId);
// update the ASN entity
logger.debug(DEBUG_UPDATING_DATABASE_FOR_EVENT_WITH_EVENT_ID, eventId);
asn.getDocuments().addAll(uploadedAttachments);
asn.setStatus(STATUS_RESUMED);
asnDao.update(asn);
logger.debug(DEBUG_UPLOADING_DOCUMENTS_FOR_EVENT_WITH_EVENT_ID_FINISHED, eventId);
response = Response.status(Response.Status.OK).entity(asn).build();
} catch (Exception e) {
logger.error(ERROR_OPERATION_WAS_NOT_SUCCESSFUL, e);
response = Response.status(Response.Status.INTERNAL_SERVER_ERROR)
.entity(RESPONSE_UPLOADING_DOCUMENT_WAS_NOT_SUCCESSFUL).build();
}
}
return response;
}