• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java MultiPartInputStreamParser类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中org.eclipse.jetty.util.MultiPartInputStreamParser的典型用法代码示例。如果您正苦于以下问题:Java MultiPartInputStreamParser类的具体用法?Java MultiPartInputStreamParser怎么用?Java MultiPartInputStreamParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

MultiPartInputStreamParser类属于org.eclipse.jetty.util包,在下文中一共展示了MultiPartInputStreamParser类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: populateAttachments

点赞 3

import org.eclipse.jetty.util.MultiPartInputStreamParser; //导入依赖的package包/类
@Override
protected void populateAttachments(HttpServletRequest request, HttpMessage message) {
    Object object = request.getAttribute("org.eclipse.jetty.servlet.MultiPartFile.multiPartInputStream");
    if (object instanceof MultiPartInputStreamParser) {
        MultiPartInputStreamParser parser = (MultiPartInputStreamParser)object;
        Collection<Part> parts;
        try {
            parts = parser.getParts();
            for (Part part : parts) {
                String contentType = part.getContentType();
                if (!contentType.startsWith("application/octet-stream")) {
                    continue;
                }

                DataSource ds = new PartDataSource(part);
                message.addAttachment(part.getName(), new DataHandler(ds));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
 

开发者ID:nkasvosve,
项目名称:beyondj,
代码行数:24,
代码来源:AttachmentHttpBinding.java

示例2: populateAttachments

点赞 3

import org.eclipse.jetty.util.MultiPartInputStreamParser; //导入依赖的package包/类
@Override
protected void populateAttachments(HttpServletRequest request, HttpMessage message) {
    Object object = request.getAttribute("org.eclipse.jetty.servlet.MultiPartFile.multiPartInputStream");
    if (object instanceof MultiPartInputStreamParser) {
        MultiPartInputStreamParser parser = (MultiPartInputStreamParser)object;
        Collection<Part> parts;
        try {
            parts = parser.getParts();
            for (Part part : parts) {
                DataSource ds = new PartDataSource(part);
                message.addAttachment(part.getName(), new DataHandler(ds));
            }
        } catch (Exception e) {
            throw new RuntimeCamelException("Cannot populate attachments", e);
        }
    }
}
 

开发者ID:HydAu,
项目名称:Camel,
代码行数:18,
代码来源:AttachmentHttpBinding.java

示例3: processArticleAndImage

点赞 3

import org.eclipse.jetty.util.MultiPartInputStreamParser; //导入依赖的package包/类
private Article processArticleAndImage(spark.Request request, String id) throws IOException, ServletException {
        request.raw().setAttribute(Request.__MULTIPART_CONFIG_ELEMENT, new MultipartConfigElement(System.getProperty("java.io.tmpdir")));
        Part articlePart = request.raw().getPart("article");
//        Article article = objectMapper.readValue(articlePart.getInputStream(), Article.class);
        Object articlePartJson = Configuration.defaultConfiguration().jsonProvider().parse(articlePart.getInputStream(), "UTF-8");
        String title = JsonPath.read(articlePartJson, "$.title");
        String body = JsonPath.read(articlePartJson, "$.body");
        Article article = new Article(title, body);
        articles.put(id, article);
        MultiPartInputStreamParser.MultiPart imagePart = (MultiPartInputStreamParser.MultiPart) request.raw().getPart("image");
        String filename = imagePart.getContentDispositionFilename();
        byte[] image = IOUtils.toByteArray(imagePart.getInputStream());
        HashMap<String, byte[]> imageMap = new HashMap<String, byte[]>() {{
            put(filename, image);
        }};
        images.put(id, imageMap);
        return article;
    }
 

开发者ID:halvards,
项目名称:sparkjava-spike,
代码行数:19,
代码来源:ArticleApi.java

示例4: GetMultipartData

点赞 2

import org.eclipse.jetty.util.MultiPartInputStreamParser; //导入依赖的package包/类
/**
 * Parses a multipart request and returns a Map with the parsed Parts as values and the parts names as keys.
 *Folder - The files will be saved in this folder.
 *MaxSize - The request maximum size.
 */
public Map GetMultipartData(String Folder, long MaxSize) throws IOException, ServletException {
	MultipartConfigElement config = new MultipartConfigElement(Folder, MaxSize, MaxSize, 81920);
	MultiPartInputStreamParser in = new MultiPartInputStreamParser(getObject().getInputStream(), getObject().getContentType(),
			config, new File(Folder));
	Collection<Part> parts = in.getParts();
	Map m = new Map();
	m.Initialize();
	for (Part p : parts) {
		MultiPartInputStreamParser.MultiPart mp = (MultiPartInputStreamParser.MultiPart)p;
		m.Put(mp.getName(),  mp);
	}
	return m;
}
 

开发者ID:AnywhereSoftware,
项目名称:B4J_Server,
代码行数:19,
代码来源:JServlet.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)