Package org.slim3.controller.upload

Examples of org.slim3.controller.upload.FileItem


                + path
                + ") must start with \"/\".");
        }
        request
            .setAttribute(ControllerConstants.FORWARD_SERVLET_PATH_KEY, path);
        Router router = RouterFactory.getRouter();
        String routingPath = router.route(request, path);
        if (routingPath != null) {
            int index = routingPath.lastIndexOf('?');
            if (index < 0) {
                path = routingPath;
            } else {
View Full Code Here


                } else {
                    ByteArrayOutputStream baos =
                        new ByteArrayOutputStream(BYTE_ARRAY_SIZE);
                    Streams.copy(stream, baos, true);
                    byte[] data = baos.toByteArray();
                    FileItem value =
                        data.length > 0 ? new FileItem(item.getFileName(), item
                            .getContentType(), data) : null;
                    if (name.endsWith(ARRAY_SUFFIX)) {
                        FileItem[] array =
                            (FileItem[]) request.getAttribute(name);
                        if (array == null) {
View Full Code Here

    private UploadService service = new UploadService();

    @Override
    public Navigation run() {
        FileItem formFile = requestScope("formFile");
        service.upload(formFile);
        return redirect(basePath);
    }
View Full Code Here

        assertThat(service.getDataList().size(), is(count + 1));
    }

    @Test
    public void upload() throws Exception {
        FileItem formFile =
            new FileItem("/root/aaa.txt", "text/html", new byte[] { 'a' });
        UploadedData data =
            Datastore
                .get(UploadedData.class, service.upload(formFile).getKey());
        assertThat(data.getFileName(), is("aaa.txt"));
        assertThat(data.getLength(), is(1));
View Full Code Here

        assertThat(fragment.getBytes(), is(new byte[] { 'a' }));
    }

    @Test
    public void getBytes() throws Exception {
        FileItem formFile =
            new FileItem("aaa.txt", "text/html", new byte[] { 'a' });
        UploadedData data = service.upload(formFile);
        assertThat(service.getBytes(data), is(new byte[] { 'a' }));
    }
View Full Code Here

    @Test
    public void delete() throws Exception {
        int count = Datastore.query(UploadedData.class).count();
        int count2 = Datastore.query(UploadedDataFragment.class).count();
        FileItem formFile =
            new FileItem("aaa.txt", "text/html", new byte[] { 'a' });
        UploadedData data = service.upload(formFile);
        service.delete(data.getKey());
        assertThat(Datastore.query(UploadedData.class).count(), is(count));
        assertThat(
            Datastore.query(UploadedDataFragment.class).count(),
View Full Code Here

public class DownloadControllerTest extends ControllerTestCase {

    @Test
    public void run() throws Exception {
        FileItem formFile =
            new FileItem("aaa.txt", "text/html", new byte[] { 'a' });
        UploadedData data = new UploadService().upload(formFile);
        tester.param("key", Datastore.keyToString(data.getKey()));
        tester.param("version", data.getVersion());
        tester.start("/upload/download");
        DownloadController controller = tester.getController();
View Full Code Here

public class ShowControllerTest extends ControllerTestCase {

    @Test
    public void run() throws Exception {
        FileItem formFile =
            new FileItem("aaa.txt", "text/html", new byte[] { 'a' });
        UploadedData data = new UploadService().upload(formFile);
        tester.param("key", Datastore.keyToString(data.getKey()));
        tester.param("version", data.getVersion());
        tester.start("/upload/show");
        ShowController controller = tester.getController();
View Full Code Here

    @Test
    public void run() throws Exception {
        int count = Datastore.query(UploadedData.class).count();
        int count2 = Datastore.query(UploadedDataFragment.class).count();
        FileItem fileItem =
            new FileItem("aaa.txt", "text/plain", new byte[] { 1 });
        tester.requestScope("formFile", fileItem);
        tester.start("/upload/upload");
        UploadController controller = tester.getController();
        assertThat(controller, is(notNullValue()));
        assertThat(tester.isRedirect(), is(true));
View Full Code Here

        controller.servletContext = servletContext;
        controller.request = request;
        controller.response = response;
        int pos = path.lastIndexOf('/');
        controller.basePath = path.substring(0, pos + 1);
        Errors errors = (Errors) request.getAttribute(ControllerConstants.ERRORS_KEY);
        if (errors == null) {
            errors = new Errors();
            request.setAttribute(ControllerConstants.ERRORS_KEY, errors);
        }
        controller.errors = errors;
        return controller;
    }
View Full Code Here

TOP

Related Classes of org.slim3.controller.upload.FileItem

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.