Hello Francois,

Friday, December 29, 2006, 1:16:14 PM, you wrote:

>> The question is, how to get rid of this header and footer safely. Is
>> it enough just to delete first 4 lines and last 5 lines or it should
>> be done some other way?

FP> You should decode it carefully. The number of header lines may vary. The
FP> last one is an empty one. Use the delimiter to find the end of data.

I see no obvious solution, I think there exists many ways to do it,
but it should be considered that we have to deal with huge amounts of
data and we need to process it fast. Suppose a user uploads a 100
megabyte file, it may take a lot of CPU and HDD time... I only could
do it as follows. I tested it with 30Mb RAR archive and it was
unpacked successfully after the upload. If you can suggest a better
way, you are welcome.


    mst:=tmemorystream.create;
    st:=tstringstream.Create(s);
    st.Write(ClientCnx.FPostedDataBuffer^,clientcnx.FDataLen);
    delimiter:=copy(st.DataString,1, pos(#13#10,st.DataString ));

    fname:=copy(st.DataString,pos('filename="', st.datastring)+10,
     posex('"',st.datastring, pos('filename="', 
st.datastring)+10)-(pos('filename="', st.datastring)+10));

    if fname='' then fname:='unknown.file';
    s1:=copy(st.DataString,pos(#13#10#13#10,st.DataString)+4, 
length(st.DataString));
    s1:=copy(s1,1, pos(delimiter,s1)-3);
    st.Position:=0;
    st.Size:=0;
    st.writeString(s1);
    mst.LoadFromStream(st);
    mst.SaveToFile('c:\'+fname);
    st.Free;
    mst.Free;



-- 
Best regards,
 tol


-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to