commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Lea <ja...@kumachan.net.nz>
Subject Re: [Commons FileUpload]understanding the source code
Date Thu, 29 Jul 2004 09:06:09 GMT
You seem to missing the line terminators, the request sent would have 
looked like this:

-----------------------------7d433743032e
Content-Disposition: form-data;
	name="file1";
	filename="C:\abc.txt"
Content-Type: text/plain

XYZ

-----------------------------7d433743032e--


They just have to process each line.  The blank line between 
Content-type: and XYZ is important, that separates the headers from the 
content.


Rommel Sharma wrote:

>Hi,
>
>This question is about the Commons FileUpload package. I hope I am posting
>to the right users list.
>
>I am trying to understand the source code, and understand the logic through
>which the data is extracted.
>
>>>From my understanding: when we use the file input tag to upload a file to
>the server using the POST method, then the data transferred looks like this:
>
>-----------------------------7d433743032eContent-Disposition: form-data;
>name="file1"; filename="C:\abc.txt"Content-Type:
>text/plainXYZ-----------------------------7d433743032e--
>
>where the content in my file is XYZ.
>
>We can write a code that  extracts the filename by parsing the inputstream.
>Now my question is that how can we extract the content XYZ as the
>Content-Type could be anything: text/plain, or text/html, or
>application/octet-stream or something else? We know that the content ends
>with the boundary (-----------------------------7d433743032e-- in this case
>in case of single file uplaod) so we know upto where the content will be,
>but how do we know the exact starting index of the content as the content
>type could vary.
>
>Also, the content length that I may extract, will give me size including
>that of the boundary and associated information also, but all I want is of
>only of the file uplaoded by the client.
>
>How did the Commons FileUpload team get across these problem? The source
>code, although very well written, looks a bit confusing to me.
>
>Thanks and Regards,
>Rommel Sharma.
>
>
>
>
>*********************************************************
>Disclaimer:          
>
>This message (including any attachments) contains 
>confidential information intended for a specific 
>individual and purpose, and is protected by law. 
>If you are not the intended recipient, you should 
>delete this message and are hereby notified that 
>any disclosure, copying, or distribution of this
>message, or the taking of any action based on it, 
>is strictly prohibited.
>
>*********************************************************
>Visit us at http://www.mahindrabt.com
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
>  
>


-- 
Jason Lea



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message