partial implementation of chunked uploading (really painful)