2013年10月5日星期六

HTTP ! HTTP ! Consult ah

I was doing a file transfer feature, you need to transfer a file to the server . But the transfer process is very unstable , the connection may be disconnected , so you need HTTP functionality.

I thought of a train of thought, I do not know right or wrong, please give some advice :
1. client obtains File file , and server to establish a connection and start through the IO stream File sent to the server.
2. If the network is disconnected between , a second transfer request before the transfer File server , gets the last unfinished File size File.length (). The client then RandomAccessFile from this length +1 place, again to the server for data transmission. Services FileOutputStream right side through the last unfinished File for additional operations.
3. If re- opened and re- transmit , repeat step 2. Until the file transfer is complete

this idea work?
I am mainly worried about step 2 , the transmission intermittent operation , will produce an error on the document itself .
------ Solution ---------------------------------------- ----
local simulate what you can do, such as a file is split into three files, and finally see if you can follow this approach you and assembled . .

------ Solution ------------------------------------ --------
thinking okay , do not try to write the code to know
------ For reference only -------------- -------------------------
tried may want to know that there is no better way

没有评论:

发表评论