1 person found this helpful
not sure if you can do this outside of AIR, but i've done it as an AIR app.
use FileStream to openAsync() a file for FileMode.READ
use FileStream's .readAhead property to define the amount of bytes you want to read in at a time
define your own chunkSize value for the size of the chunked files
use the ProgressEvent fired by FileStream to let you know when enough bytes are available to fill a buffer of chunkSize
create a new File and write those chunkSize bytes into it
when that file has finished writing to the local disk, use File.upload() to upload it to your server
repeat until all chunks are there. using openAsync with a smaller chunk size means you don't have to load the entire file into memory. using File.upload() gives you upload progress. (Sockets are still broken in as3 in that they don't report the progress of the file)
it's quite simple to set up your own mini protocol for resuming broken transfers. just keep track of the last chunk index that was successfully uploaded, and start from that index to resume a broken upload. reassembling the chunked files back into the original file on the server side is trivial.
i don't think this will work without a lot of user intervention in a flash app running inside a browser, due to flash's security restrictions. with flash 10 you can write to the local disk, yes, but i believe manual user intervention/permission is required each time. furthermore, i don't think you could upload() the chunk files that were dynamically created without manual user intervention/permission for security reasons.
I was trying to keep this in the browser, I may be force to go to java on this, although AIR would work most of our corporate clients are not allowed to install desktop apps with out involving their IT departmentI was hoping for some extra call in load like read ahead and part load the file in memory and upload that part read.
Will appreciate if you could share the piece of code chunking the files in AIR with us, as the Adobe's example code for readAhead seems worthless. Really appreciate if you could share.