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


Java MediaType.MULTIPART_FORM_DATA属性代码示例

本文整理汇总了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);
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:19,代码来源:PaymentFileManagement.java

示例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);
    }
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:23,代码来源:CustomConnectorHandler.java

示例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"));
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:15,代码来源:PubAnnotation.java

示例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);
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:23,代码来源:DossierFileManagement.java

示例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();
}
 
开发者ID:jesuino,项目名称:java-ml-projects,代码行数:9,代码来源:DataSetResource.java

示例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);
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:31,代码来源:ConnectorHandler.java

示例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);
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:9,代码来源:OfficeSiteManagement.java

示例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);
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:12,代码来源:InputFieldResource.java

示例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);
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:12,代码来源:StaffResource.java

示例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();
}
 
开发者ID:Comcast,项目名称:redirector,代码行数:10,代码来源:OfflineRedirectorController.java

示例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;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:37,代码来源:HomeResource.java

示例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();
}
 
开发者ID:minijax,项目名称:minijax,代码行数:8,代码来源:FormParamTest.java

示例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);
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:18,代码来源:DossierLogManagement.java

示例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);
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:9,代码来源:UserManagement.java

示例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;
}
 
开发者ID:SAP,项目名称:cloud-ariba-partner-flow-extension-ext,代码行数:62,代码来源:EventResource.java


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