Package org.apache.cocoon.servlet.multipart

Examples of org.apache.cocoon.servlet.multipart.Part


            }
        }
    }
   
    public static void save(Request request, String param, String dest) throws Exception {
        Part part = (Part) request.get(param);
        save(part, (ModifiableTraversableSource)env.resolveURI(dest));
    }
View Full Code Here


                                    a.getType(src.getMimeType()),
                                    a.getName(name.substring(name.lastIndexOf('/') + 1)));
                        }
                    } else {
                        if (a.getObject() instanceof Part) {
                            Part part = (Part) a.getObject();
                            ds = new FilePartDataSource(
                                    part,
                                    a.getType(part.getMimeType()),
                                    a.getName(part.getUploadName()));
                        } else {
                            // TODO: other classes?
                            throw new AddressException("Not yet supported: " + a.getObject());
                        }
                    }
View Full Code Here

        getLogger().info("upload source called by '"+principal+"' for '"+uri+"'");

        Object uploadedFile = request.get(UPLOAD_FILE);
       
        if (( uploadedFile != null) && (uploadedFile instanceof Part)) {
            Part part = (Part) uploadedFile;
           
            try {
                if ((filename == null) || (filename.length() == 0)) {
                    filename = part.getFileName();
                }

                if ((uri == null) || (uri.length() == 0))
                    uri = filename;
                else if (uri.endsWith("/"))
                    uri = uri + filename;
                else
                    uri = uri + "/" + filename;

                Source source = resolver.resolveURI(uri);

                if (source instanceof RestrictableSource)
                    ((RestrictableSource)source).setSourceCredential(new SourceCredential(principal, password));

                if (source instanceof ModifiableSource) {
                    ModifiableSource writeablesource = (ModifiableSource)source;

                    OutputStream out = writeablesource.getOutputStream();

                    byte[] buffer = new byte[8192];
                    int length = -1;

                    InputStream in = part.getInputStream();
                    while ((length = in.read(buffer)) > -1) {
                        out.write(buffer, 0, length);
                        getLogger().debug("="+length);
                    }
                    in.close();
View Full Code Here

     * @throws Exception when something went wrong.
     */
    public File save(Request request, String requestParameter)
            throws Exception {

        Part part = (Part) request.get(requestParameter);

        File file = null;
       
        boolean success = save(part);
        if (success) {
            file = new File(directory, part.getFileName());
        }

        return file;
    }
View Full Code Here

TOP

Related Classes of org.apache.cocoon.servlet.multipart.Part

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.