better handle of error

callback with err when upload failed.