users@jersey.java.net

[Jersey] Re: how to upload large file more then 2 gb using jersey?

From: Noah White <emailnbw_at_gmail.com>
Date: Wed, 29 Feb 2012 20:46:18 -0500

Actually this is exposed in the Admin UI but you have to go to Configurations -> server-config -> Network Config -> Network Listeners -> http-listener-1 and then click on the HTTP tab and you will see it in there.

-Noah

On Feb 29, 2012, at 8:38 PM, Noah White wrote:

> What server are you using? It looks like in Glassfish there's a server-config property for Grizzly that establishes a max-post-size-bytes which by default is 2097152. If you are using Grizzly/Glassfish you are probably running into that.
>
> You can use:
>
> asadmin set server-config.network-config.protocols.protocol.http-listener-1.http.max-post-size-bytes=new_value
>
> to adjust this for the default non-SSL HTTP listener.
>
> It doesn't look like this property is exposed in the GF Admin UI.
>
> -Noah
>
> On Feb 15, 2012, at 1:02 AM, Vipin.nemade wrote:
>
>> Hi Pavel,
>>
>> I am using jersey multipart jar to upload a file.my server is crashing when
>> file 2gb or more then 2gb.
>>
>> my code of rest webservice:-
>>
>>
>>
>> @POST
>> @Consumes(MediaType.MULTIPART_FORM_DATA)
>> public Response uploadFile(@FormDataParam('file')InputStream
>> uploadedInputStream,_at_FormDataParam('file') FormDataContentDisposition
>> fileDetail,_at_HeaderParam("Content-Length") int length) {
>>
>> println("Content-Lenght:"+""+length)
>>
>> if(uploadedInputStream != null)
>> println("contain stream")
>>
>> if(fileDetail != null)
>> println("contain file :"+fileDetail.getFileName())
>> String name = getFileName(fileDetail.getFileName())
>> println("File Name is:"+" "+name)
>> String uploadedFileLocation = "D://uploaded/"+name;
>>
>>
>> writeToFile(uploadedInputStream,uploadedFileLocation);
>> println("Test3")
>> String output = "File uploaded to : " + uploadedFileLocation;
>> return Response.status(200).entity("uploadFile size"+" "+length+"bytes"+"
>> "+"Uploaded file name : " +name).build();
>>
>>
>> }
>>
>> // save uploaded file to new location
>> private void writeToFile(InputStream uploadedInputStream,String
>> uploadedFileLocation) {
>>
>> try {
>> OutputStream out = new FileOutputStream(new File(uploadedFileLocation));
>> int read = 0;
>> byte[] bytes = new byte[1024];
>>
>> out = new FileOutputStream(new File(uploadedFileLocation));
>> while ((read = uploadedInputStream.read(bytes)) != -1) {
>> out.write(bytes,0,read);
>> }
>> out.flush();
>> out.close();
>> } catch (IOException e) {
>>
>> e.printStackTrace();
>> }
>>
>> }
>> Please help me to achive more then 2 gb file.
>>
>> --
>> View this message in context: http://jersey.576304.n2.nabble.com/how-to-upload-large-file-more-then-2-gb-using-jersey-tp7283481p7286671.html
>> Sent from the Jersey mailing list archive at Nabble.com.
>