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


Java MultiPartFeature類代碼示例

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


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

示例1: initClient

import org.glassfish.jersey.media.multipart.MultiPartFeature; //導入依賴的package包/類
private static void initClient() {
  JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
  ObjectMapper objectMapper = JSONUtil.prettyMapper();
  objectMapper.registerModule(
    new SimpleModule()
      .addDeserializer(JobDataFragment.class,
        new JsonDeserializer<JobDataFragment>() {
          @Override
          public JobDataFragment deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
            return jsonParser.readValueAs(DataPOJO.class);
          }
        }
      )
  );
  provider.setMapper(objectMapper);
  client = ClientBuilder.newBuilder().register(provider).register(MultiPartFeature.class).build();
  WebTarget rootTarget = client.target("http://localhost:" + currentDremioDaemon.getWebServer().getPort());
  currentApiV2 = rootTarget.path(API_LOCATION);
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:20,代碼來源:TestMasterDown.java

示例2: testPassThroughPostMultiPart

import org.glassfish.jersey.media.multipart.MultiPartFeature; //導入依賴的package包/類
/**
 * Test to make sure that the proxy can proxy a redirect
 * @throws Exception
 */
@Test
public void testPassThroughPostMultiPart() throws Exception {
    final FileDataBodyPart filePart = new FileDataBodyPart("test_file", new File(TEST_IMAGE_PATH));

    MultiPart multiPart = new FormDataMultiPart()
            .field("foo", "bar")
            .bodyPart(filePart);
    Client multipartClient = ClientBuilder.newBuilder()
            .register(MultiPartFeature.class)
            .build();
    String responseBody = multipartClient.target("http://localhost:" + RULE.getLocalPort() + "/proxy")
            .request()
            .header("proxy-url", "http://httpbin.org/post")
            .post(Entity.entity(multiPart, multiPart.getMediaType()))
            .readEntity(String.class);
    assertTrue(responseBody.toLowerCase().contains("test_file"));
}
 
開發者ID:kunai-consulting,項目名稱:KeyStor,代碼行數:22,代碼來源:IntegrationTest.java

示例3: XbddApplication

import org.glassfish.jersey.media.multipart.MultiPartFeature; //導入依賴的package包/類
public XbddApplication() {
	packages(getClass().getPackage().getName());

	// MVC feature
	property(JspMvcFeature.TEMPLATE_BASE_PATH, "/WEB-INF/jsp");
	register(JspMvcFeature.class);
	register(MultiPartFeature.class);

	// Logging.
	// register(LoggingFilter.class);

	property(ServerProperties.TRACING, TracingConfig.ON_DEMAND.name());

	register(new AbstractBinder() {
		@Override
		protected void configure() {
			bindFactory(ServletContextMongoClientFactory.class).to(MongoDBAccessor.class).in(Singleton.class);
		}
	});
}
 
開發者ID:orionhealth,項目名稱:XBDD,代碼行數:21,代碼來源:XbddApplication.java

示例4: init

import org.glassfish.jersey.media.multipart.MultiPartFeature; //導入依賴的package包/類
@BeforeClass
public static void init() throws Exception {
  try (TimedBlock b = Timer.time("[email protected]")) {
    dremioDaemon = DACDaemon.newDremioDaemon(
      DACConfig
        .newDebugConfig(DremioTest.DEFAULT_SABOT_CONFIG)
        .autoPort(true)
        .allowTestApis(true)
        .writePath(folder.getRoot().getAbsolutePath())
        .clusterMode(ClusterMode.LOCAL)
        .serveUI(true),
        DremioTest.CLASSPATH_SCAN_RESULT);
    dremioDaemon.init();
    JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
    provider.setMapper(JSONUtil.prettyMapper());
    client = ClientBuilder.newBuilder().register(provider).register(MultiPartFeature.class).build();
    rootTarget = client.target("http://localhost:" + dremioDaemon.getWebServer().getPort());
  }
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:20,代碼來源:TestUIServer.java

示例5: initMasterClient

import org.glassfish.jersey.media.multipart.MultiPartFeature; //導入依賴的package包/類
private static void initMasterClient() {
  JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
  ObjectMapper objectMapper = JSONUtil.prettyMapper();
  objectMapper.registerModule(
    new SimpleModule()
      .addDeserializer(JobDataFragment.class,
        new JsonDeserializer<JobDataFragment>() {
          @Override
          public JobDataFragment deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
            return jsonParser.readValueAs(DataPOJO.class);
          }
        }
      )
  );
  provider.setMapper(objectMapper);
  masterClient = ClientBuilder.newBuilder().register(provider).register(MultiPartFeature.class).build();
  WebTarget rootTarget = masterClient.target("http://localhost:" + masterDremioDaemon.getWebServer().getPort());
  masterApiV2 = rootTarget.path(API_LOCATION);
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:20,代碼來源:TestMasterDown.java

示例6: run

import org.glassfish.jersey.media.multipart.MultiPartFeature; //導入依賴的package包/類
@Override
public void run(BlogConfiguration blogConfiguration, Environment environment) throws Exception {
    final BlogDao blogDao = new BlogDao(hibernate.getSessionFactory());

    // Register all resources here.
    environment.jersey().register(new BlogResources(blogDao));
    environment.jersey().register(new UploadResources());
    environment.jersey().register(new UnitTestResources());

    // Register MultiPartFeature.class to support mime type "multipart/form-data."
    environment.jersey().getResourceConfig().register(MultiPartFeature.class);

    // All Filter
    // CORS enable
    Dynamic filter = environment.servlets().addFilter("CORS", CrossOriginFilter.class);
    filter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), false, "/*");
    filter.setInitParameter(CrossOriginFilter.ALLOWED_METHODS_PARAM, "GET,PUT,POST,DELETE,OPTIONS");
    filter.setInitParameter(CrossOriginFilter.ALLOWED_ORIGINS_PARAM, "*");
    filter.setInitParameter(CrossOriginFilter.ACCESS_CONTROL_ALLOW_ORIGIN_HEADER, "*");
    filter.setInitParameter("allowedHeaders", "Content-Type,Authorization,X-Requested-With,Content-Length,Accept,Origin");
    filter.setInitParameter("allowCredentials", "true");

}
 
開發者ID:zslucky,項目名稱:dropwizard-myblog,代碼行數:24,代碼來源:BlogApplication.java

示例7: JbrickWSApplication

import org.glassfish.jersey.media.multipart.MultiPartFeature; //導入依賴的package包/類
public JbrickWSApplication() {
	// Registrazione del package contenente le risorse
	packages("it.makeit.jbrick.ws.resources"); 
	packages("it.makeit.profiler.ws.resources");
	packages("it.makeit.jbrick.configdb.ws.resources");
	packages("it.makeit.jbrick.scheduler.ws.resources");
	packages("it.makeit.zefiro.ws.resources");

	// Registrazione di jackson-media-provider e configurazione serializzatore
	register(JacksonFeature.class);
	register(JbrickJacksonConfigurator.class);

	// Registrazione del listener delle eccezioni
	register(ExceptionListener.class);
	
	// Registrazione exception mapper
	register(JbrickExceptionMapper.class);
	
	// Registrazione Multipart Feature per upload file
	register(MultiPartFeature.class);
	
	// Registrazione filtri
	register(AuthenticationFilter.class);
	register(LogFilter.class);
}
 
開發者ID:MakeITBologna,項目名稱:zefiro,代碼行數:26,代碼來源:JbrickWSApplication.java

示例8: main

import org.glassfish.jersey.media.multipart.MultiPartFeature; //導入依賴的package包/類
/**
 * <p>main.</p>
 *
 * @param args an array of {@link java.lang.String} objects.
 * @throws java.lang.Exception if any.
 */
@SuppressWarnings("resource")
public static void main(final String[] args) throws Exception
{
    final ResourceConfig config = new ResourceConfig();
    config.register(PresentationResourceImpl.class);
    config.register(MultiPartFeature.class);

    final Closeable simpleContainer = SimpleContainerFactory.create(new URI("http://0.0.0.0:8181"),
        config);

    System.out.println("Strike ENTER to stop...");
    new Scanner(System.in).nextLine();

    simpleContainer.close();

    System.out.println("Bye!");
    System.exit(0);
}
 
開發者ID:OnPositive,項目名稱:aml,代碼行數:25,代碼來源:Main.java

示例9: main

import org.glassfish.jersey.media.multipart.MultiPartFeature; //導入依賴的package包/類
/**
 * <p>main.</p>
 *
 * @param args an array of {@link java.lang.String} objects.
 * @throws java.lang.Exception if any.
 */
@SuppressWarnings("resource")
public static void main(final String[] args) throws Exception
{
    final ResourceConfig config = new ResourceConfig();
    config.register(OrgsIdResourceImpl.class);
    config.register(MultiPartFeature.class);

    final Closeable simpleContainer = SimpleContainerFactory.create(new URI("http://0.0.0.0:8181"),
        config);

    System.out.println("Strike ENTER to stop...");
    new Scanner(System.in).nextLine();

    simpleContainer.close();

    System.out.println("Bye!");
    System.exit(0);
}
 
開發者ID:OnPositive,項目名稱:aml,代碼行數:25,代碼來源:Main.java

示例10: main

import org.glassfish.jersey.media.multipart.MultiPartFeature; //導入依賴的package包/類
public static void main(String[] args) throws IOException
{
    final Client client = ClientBuilder.newBuilder().register(MultiPartFeature.class).build();
 
    final FileDataBodyPart filePart = new FileDataBodyPart("file", new File("/tmp/Sample.pdf"));
    FormDataMultiPart formDataMultiPart = new FormDataMultiPart();
    final FormDataMultiPart multipart = (FormDataMultiPart) formDataMultiPart.field("foo", "bar").bodyPart(filePart);
      
    final WebTarget target = client.target(getBaseURI());
    final Response response = target.request().post(Entity.entity(multipart, multipart.getMediaType()));
     
    //Use response object to verify upload success
     if (response.getStatus() != 200) {
          throw new RuntimeException("Failed : HTTP error code : "
           + response.getStatus());
       } else {
		System.out.println("Data uploaded successfully !!\n");
	}	
    
    formDataMultiPart.close();
    multipart.close();
}
 
開發者ID:zekaf,項目名稱:jetty-nodes,代碼行數:23,代碼來源:UploadFileTest.java

示例11: SchedulerApiServer

import org.glassfish.jersey.media.multipart.MultiPartFeature; //導入依賴的package包/類
public SchedulerApiServer(SchedulerConfig schedulerConfig, Collection<Object> resources) {
    this.port = schedulerConfig.getApiServerPort();
    this.server = JettyHttpContainerFactory.createServer(
            UriBuilder.fromUri("http://0.0.0.0/").port(this.port).build(),
            new ResourceConfig(MultiPartFeature.class).registerInstances(new HashSet<>(resources)),
            false /* don't start yet. wait for start() call below. */);
    this.startTimeout = schedulerConfig.getApiServerInitTimeout();

    ServletContextHandler context = new ServletContextHandler();

    // Metrics + Prometheus
    Metrics.configureMetricsEndpoints(context, "/v1/metrics", "/v1/metrics/prometheus");

    // Resources
    ResourceConfig resourceConfig = new ResourceConfig(MultiPartFeature.class)
            .registerInstances(new HashSet<>(resources));
    ServletHolder resourceHolder = new ServletHolder(new ServletContainer(resourceConfig));
    context.addServlet(resourceHolder, "/*");

    final InstrumentedHandler handler = new InstrumentedHandler(Metrics.getRegistry());
    handler.setHandler(context);
    server.setHandler(handler);
}
 
開發者ID:mesosphere,項目名稱:dcos-commons,代碼行數:24,代碼來源:SchedulerApiServer.java

示例12: configure

import org.glassfish.jersey.media.multipart.MultiPartFeature; //導入依賴的package包/類
@Override
public boolean configure(FeatureContext context) {
    context.register(MoxyJsonFeature.class);
    context.register(MoxyXmlFeature.class);
    context.register(MultiPartFeature.class);

    // internal features
    context.register(CacheFilter.class);
    context.register(GenericExceptionMapper.class);
    context.register(XmlMessageBodyReader.class);
    context.register(XmlMessageBodyWriter.class);

    Configuration.instance().getStrings("APP.Jersey.Features").forEach(cn -> {
        try {
            LOGGER.info("Register Jersey Feature: {}", cn);
            context.register(this.getClass().getClassLoader().loadClass(cn));
        } catch (ClassNotFoundException e) {
            LOGGER.error(e.getMessage(), e);
        }
    });

    return true;
}
 
開發者ID:MyCoRe-Org,項目名稱:MyVidCoRe,代碼行數:24,代碼來源:FrontendFeature.java

示例13: ALEXApplication

import org.glassfish.jersey.media.multipart.MultiPartFeature; //導入依賴的package包/類
/**
 * Constructor where the magic happens.
 */
public ALEXApplication() {
    // REST Resources
    register(CounterResource.class);
    register(FileResource.class);
    register(LearnerResource.class);
    register(LearnerResultResource.class);
    register(ProjectResource.class);
    register(SettingsResource.class);
    register(SymbolGroupResource.class);
    register(SymbolResource.class);
    register(UserResource.class);
    register(TestResource.class);

    // Exceptions
    register(NotFoundExceptionMapper.class);

    // Other
    register(MultiPartFeature.class);
    register(AuthenticationFilter.class);
    register(RolesAllowedDynamicFeature.class); // allow protecting routes with user roles
    register(JacksonConfiguration.class);
}
 
開發者ID:LearnLib,項目名稱:alex,代碼行數:26,代碼來源:ALEXApplication.java

示例14: shouldUploadAFile

import org.glassfish.jersey.media.multipart.MultiPartFeature; //導入依賴的package包/類
@Test
    public void shouldUploadAFile() {
        Path path = Paths.get(System.getProperty("user.dir"),
                              "src", "test", "resources", "rest", "IFrameProxyTestData.html");
        FileDataBodyPart filePart = new FileDataBodyPart("file", path.toFile());
        filePart.setContentDisposition(FormDataContentDisposition.name("file")
                                               .fileName("IFrameProxyTestData.html")
                                               .build());
        MultiPart multipartEntity = new FormDataMultiPart().bodyPart(filePart);
        Response response = target("/projects/" + PROJECT_TEST_ID + "/files")
                                .register(MultiPartFeature.class)
                                .request()
                                .post(Entity.entity(multipartEntity, MediaType.MULTIPART_FORM_DATA));
        System.out.println(" -> " + response.readEntity(String.class));
//        assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    }
 
開發者ID:LearnLib,項目名稱:alex,代碼行數:17,代碼來源:FileResourceTest.java

示例15: configure

import org.glassfish.jersey.media.multipart.MultiPartFeature; //導入依賴的package包/類
@Override
protected Application configure() {
    final ResourceConfig application =
            new ResourceConfig(TestWebserviceWithPath.class, TestWebserviceWithPutDelete.class,
                    TestWebserviceMultipart.class, TestWebserviceExceptionHandling.class,
                    JacksonJsonProvider.class);
    final Injector injector =
            Guice.createInjector(new ClientModule(), new ExceptionObjectMapperModule());

    // register multi part feature.
    application.register(MultiPartFeature.class);

    // register the application mapper.
    application.register(injector.getInstance(TestExceptionMapper.class));
    return application;
}
 
開發者ID:strandls,項目名稱:alchemy-rest-client-generator,代碼行數:17,代碼來源:AlchemyRestClientFactoryTest.java


注:本文中的org.glassfish.jersey.media.multipart.MultiPartFeature類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。