Package org.apache.cxf.jaxrs.ext.multipart

Examples of org.apache.cxf.jaxrs.ext.multipart.InputStreamDataSource


    }

    public Object readFrom(Class cls, Type genericType, Annotation[] annotations,
                               MediaType type, MultivaluedMap headers, InputStream is)
        throws IOException {
        DataSource ds = new InputStreamDataSource(is, type.toString());
        return DataSource.class.isAssignableFrom(cls) ? ds : new DataHandler(ds);
    }
View Full Code Here


    }
   
    @Test
    public void testWriteDataHandler() throws Exception {
        DataSourceProvider p = new DataSourceProvider();
        DataHandler ds = new DataHandler(new InputStreamDataSource(
                             new ByteArrayInputStream("image".getBytes()),
                             "image/png"));
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        p.writeTo(ds, DataHandler.class, DataHandler.class, new Annotation[]{},
                   MediaType.valueOf("image/png"), new MetadataMap<String, Object>(), os);
View Full Code Here

    }
   
    @Test
    public void testWriteDataSource() throws Exception {
        DataSourceProvider p = new DataSourceProvider();
        DataSource ds = new InputStreamDataSource(new ByteArrayInputStream("image".getBytes()),
                                                  "image/png");
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        MultivaluedMap<String, Object> outHeaders = new MetadataMap<String, Object>();
       
        p.writeTo(ds, DataSource.class, DataSource.class, new Annotation[]{},
View Full Code Here

    }
   
    @Test
    public void testWriteDataSourceWithDiffCT() throws Exception {
        DataSourceProvider p = new DataSourceProvider();
        DataSource ds = new InputStreamDataSource(new ByteArrayInputStream("image".getBytes()),
                                                  "image/png");
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        MultivaluedMap<String, Object> outHeaders = new MetadataMap<String, Object>();
        p.writeTo(ds, DataSource.class, DataSource.class, new Annotation[]{},
                   MediaType.valueOf("image/bar"), outHeaders, os);
View Full Code Here

    }
   
    @Test
    public void testWriteDataHandler() throws Exception {
        DataSourceProvider<DataHandler> p = new DataSourceProvider<DataHandler>();
        DataHandler ds = new DataHandler(new InputStreamDataSource(
                             new ByteArrayInputStream("image".getBytes()),
                             "image/png"));
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        p.writeTo(ds, DataHandler.class, DataHandler.class, new Annotation[]{},
                   MediaType.valueOf("image/png"), new MetadataMap<String, Object>(), os);
View Full Code Here

    }
   
    @Test
    public void testWriteDataSource() throws Exception {
        DataSourceProvider<DataSource> p = new DataSourceProvider<DataSource>();
        DataSource ds = new InputStreamDataSource(new ByteArrayInputStream("image".getBytes()),
                                                  "image/png");
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        MultivaluedMap<String, Object> outHeaders = new MetadataMap<String, Object>();
       
        p.writeTo(ds, DataSource.class, DataSource.class, new Annotation[]{},
View Full Code Here

   
    @Test
    public void testWriteDataSourceWithDiffCT() throws Exception {
        DataSourceProvider<DataSource> p = new DataSourceProvider<DataSource>();
        p.setUseDataSourceContentType(true);
        DataSource ds = new InputStreamDataSource(new ByteArrayInputStream("image".getBytes()),
                                                  "image/png");
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        MultivaluedMap<String, Object> outHeaders = new MetadataMap<String, Object>();
        p.writeTo(ds, DataSource.class, DataSource.class, new Annotation[]{},
                   MediaType.valueOf("image/jpeg"), outHeaders, os);
View Full Code Here

        } else if (toMap instanceof DataSource) {
            dh = new DataHandler((DataSource) toMap);
        } else if (toMap instanceof DataHandler) {
            dh = (DataHandler) toMap;
        } else if (toMap instanceof InputStream) {
            dh = new DataHandler(new InputStreamDataSource((InputStream) toMap, multipartType == null ? "application/octet-stream" : multipartType));
        }
        if (dh != null) {
            in.addAttachment(parameterName, dh);
        }
    }
View Full Code Here

        }
        return new MessageBodyWriterDataHandler(r, obj, cls, genericType, anns, mt);
    }
   
    private DataHandler createInputStreamDH(InputStream is, String mimeType) {
        return new DataHandler(new InputStreamDataSource(is, mimeType));
    }
View Full Code Here

        Class<T> cls = (Class<T>)obj.getClass();
        return getHandlerForObject(obj, cls, genericType, anns, mimeType, id);
    }
   
    private DataHandler createInputStreamDH(InputStream is, String mimeType) {
        return new DataHandler(new InputStreamDataSource(is, mimeType));
    }
View Full Code Here

TOP

Related Classes of org.apache.cxf.jaxrs.ext.multipart.InputStreamDataSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.