Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: MultipartEntity content length not same as file size

  1. #1
    Junior Member
    Join Date
    Aug 2013
    Posts
    3
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default MultipartEntity content length not same as file size

    Hello all,

    I'm having an issue with my java uploader. I am creating a MultipartEntity but something is padding the file size with an additional 234 bytes so the upload is failing.

    in the following code, contentLength is 1241572 bytes but my actual file size is 1241338 bytes.
    Can someone tell me what is adding these additional bytes or how to bebug this?
    The upload fails because the server responds with "Body size does not match filesize."

    File file = new File(tempPath + '/' + "upload-test.mov");
    MultipartEntity entity = new MultipartEntity();
    ContentBody body = new FileBody(file, "multipart/mixed");
    entity.addPart("upload-test.mov", body);
    long contentLength = entity.getContentLength();  //content length is larger than source file by 234 bytes

    (I noticed when I change the mime type to something other than "multipart/mixed" the content size changes.. I just want raw data!)

    Thanks for any help.



    -Tavis


  2. #2
    Member
    Join Date
    Jul 2013
    Posts
    219
    Thanks
    0
    Thanked 18 Times in 17 Posts

    Default Re: MultipartEntity content length not same as file size

    Hello.
    If your application is a web application and you are uploading files from client to server then you can use Java Zoom API (UploadBean - API and Design).
    Thats just a friendly suggestion if your problem is still existing. I am not familiar with MultiPartEntiry API.

    Syed.

  3. #3
    Junior Member
    Join Date
    Aug 2013
    Posts
    3
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: MultipartEntity content length not same as file size

    i solved it by using FileEntity instead.

Similar Threads

  1. Need Help for set default size (width and length) of table using 'XWPFTable'
    By nareshdev in forum What's Wrong With My Code?
    Replies: 4
    Last Post: June 14th, 2013, 03:55 AM
  2. Replies: 4
    Last Post: February 14th, 2012, 03:28 PM
  3. Content in text file to MS Word file help!
    By ComputerSaysNo in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: October 27th, 2011, 12:39 PM
  4. Limit File Size or Request Size
    By tarek.mostafa in forum Java Servlet
    Replies: 3
    Last Post: June 12th, 2010, 05:28 PM
  5. Limit File Size or Request Size
    By tarek.mostafa in forum JavaServer Pages: JSP & JSTL
    Replies: 3
    Last Post: June 11th, 2010, 08:21 AM

Tags for this Thread