Solved

Java Multipart file upload

Posted on 2009-05-19
9
986 Views
Last Modified: 2012-06-27
I am attempting to write a code which will upload a file in parts using a POST request. With every part, I need to send following lines in the POST body,

FILENAME: xxx
LENGTH:  xxx
MD5:  xxx
SESSIONID: xxx
PARTS:x

===PART:x===
<part of the file here>
===END:md5 checksum===

After sending a part, I have to wait for a 202 response and then send the next part.

Any ideas on how to do this?
0
Comment
Question by:neerhajnjoshi
  • 4
  • 2
  • 2
9 Comments
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
Two ways basically:

a. get that info before you construct the request and add it as post params
b. subclass the request itself
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 168 total points
Comment Utility
(Your can use Apache HttpClient's multipart)
0
 
LVL 92

Assisted Solution

by:objects
objects earned 332 total points
Comment Utility
0
 

Author Comment

by:neerhajnjoshi
Comment Utility
@CEHJ,

how do I wait for a response before sending out next part ?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 92

Expert Comment

by:objects
Comment Utility
what are you using to send the request?  Once yo have sent the request you need to read the request (which will include the 202 response code which you need to read, don't just assume it there)
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
0
 

Author Comment

by:neerhajnjoshi
Comment Utility
I am aware how to send simple POST/GET requests.  It would be great if anyone could post a sample of multipart post request.
0
 
LVL 92

Assisted Solution

by:objects
objects earned 332 total points
Comment Utility
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction This warning has to be one of the most commonly issued warnings in the history of PHP.  The article explains why this warning arises and what to do to mitigate the problem. How this Happens HTTP headers include many different kinds…
Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now