Multi-part construction through HTMLUnit

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Multi-part construction through HTMLUnit

Ronald Brill
Hi Vasu,

sorry for not responding, but i have some problems with the mailings lists at the moment.

As a quick guess i think you have to use the multiple option for your file upload to be able to select many files (from the same folder) for upload.
Something like this...

        <input name="filesToUpload[]" id="filesToUpload" type="file" multiple="" />

To support this from HtmlUnit the HtmlFileInput offers a setValueAttribute method getting an array of file names.
Hope that helps...

BTW Please use the latest snapshot build instead of the release; we did a lot of fixes also for file upload during the last months.


    RBRi
    --------------------------
    WETATOR
    Smart web application testing
    http://www.wetator.org

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Htmlunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Multi-part construction through HTMLUnit

Vasudevan Comandur
Hi Ronald,

    Thanks for the reply.

     I tried creating multiple input type="file" within in a sample form.  But the server side rejects that stating that it should have
     only one filename in the Multi-part.

    In my case, they are expecting one multi-part with body being text having its own content type and the other is a binary part.

    Looks like this type of multi-part creation through HTMLUnit is not possible.

    Let me know if there is any alternate way. Perhaps, I might have to use the HTTPClient interface for constructing the multi-part.


Regards
 Vasu

On 6 January 2017 at 19:17, Ronald Brill <[hidden email]> wrote:
Hi Vasu,

sorry for not responding, but i have some problems with the mailings lists at the moment.

As a quick guess i think you have to use the multiple option for your file upload to be able to select many files (from the same folder) for upload.
Something like this...

        <input name="filesToUpload[]" id="filesToUpload" type="file" multiple="" />

To support this from HtmlUnit the HtmlFileInput offers a setValueAttribute method getting an array of file names.
Hope that helps...

BTW Please use the latest snapshot build instead of the release; we did a lot of fixes also for file upload during the last months.


    RBRi
    --------------------------
    WETATOR
    Smart web application testing
    http://www.wetator.org

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Htmlunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-user


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Htmlunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Multi-part construction through HTMLUnit

Ronald Brill
In reply to this post by Ronald Brill
Hi Vasu,

i'm not talking about many input items.

There is an option to switch an file input into multi file mode - the 'multiple' attribute.
>
> <input name="filesToUpload[]" id="filesToUpload" type="file" multiple="" />
>

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Htmlunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Multi-part construction through HTMLUnit

Vasudevan Comandur
Hi Ronald,

   Thanks for the reply. I am copying below the request body as expected by the server.

Example request body

 

--boundary_string

Content-Disposition: form-data; name="entity_content";

Content-Type: application/json

{

"ContentDocumentId" :  <nullvalue> ,

"ReasonForChange" : "New Profile created from SixthSense",

"PathOnClient" : "<file name with extension>"

}

--boundary_string

Content-Type: application/octet-stream

Content-Disposition: form-data; name="VersionData"; filename="<file name with extension>"

<Binary data goes here.>

--boundary_string--

 

 Is the above request body construction is achievable through HTMLUnit?

Regards
 Vasu



On 6 January 2017 at 21:37, Ronald Brill <[hidden email]> wrote:
Hi Vasu,

i'm not talking about many input items.

There is an option to switch an file input into multi file mode - the 'multiple' attribute.
>
>       <input name="filesToUpload[]" id="filesToUpload" type="file" multiple="" />
>

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Htmlunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-user


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Htmlunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Multi-part construction through HTMLUnit

Ronald Brill
In reply to this post by Ronald Brill
Your request body looks like a 'normal' body sent from a file upload defined with the multiple option enabled - give it a try

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Htmlunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-user