uploader to Jersey API

I’m evaluating Webix for hopeful purchase. I’m attempting to do a basic file upload. Without using Webix, this HTML works properly:

    <form action="/CMT_PG/rs/CMT/uploadExperiment" method="post" enctype="multipart/form-data">
    <p>Select a file : <input type="file" name="fileToUpload" size="50" /></p>
    <input type="submit" value="Upload It" />
    </form>

when I upload to a Java/Jersey API that looks like this:

    @POST
    @Path("/uploadExperiment")
    @Consumes(MediaType.MULTIPART_FORM_DATA)
    @Produces("application/html")
    public Response uploadExperiment(@FormDataParam("fileToUpload") InputStream uploadedInputStream,
                                   @FormDataParam("fileToUpload") FormDataContentDisposition fileDetail) {

        // etc
    }

When i try to do the upload with Webix, my two parameters to uploadExperiment() come up null:

    webix.ready(function() {
        webix.ui({
            container:"uploader_container",
            view:"form", elements: [
                {
                    view: "uploader", id:"fileToUpload", name:"fileToUpload",
                    autosend: false, multiple:false, value: 'Select File',
                    link: "mylist",  upload: "/CMT_PG/rs/CMT/uploadExperiment"
                },
                {
                    view:"list",  id:"mylist", type:"uploader",
                    autoheight:true, borderless:true
                },
                { view: "button", label: "Upload File", click: function() {
                    $$("fileToUpload").send(function(response){
                        if(response)
                            webix.message(response.status);
                    });
                }}
            ]
        });

        $$("fileToUpload").attachEvent("onUploadComplete", function() {
             webix.message("done");
         });
    });

What am I doing wrong?

Thanks!
John

Hello John,

Uploader does not use form for upload. Please check the Managing Server Part of Uploading article.

yes, i read through that link before posting, but the example is in PHP, not Java. The article says, ‘Uploader is based on an HTML input, type “file”’, which sounds like a form field to meet. I can’t figure out how this translates to a Jersey-based RESTful service.

Uploader uses file uploading by ajax, so it works a bit differently than common file control.

Code which you are using result in data output like next

As you can see , this is a common form upload request, the name of file parameter is “upload”