/// <summary> /// Asynchronous method to handle the completion of the file upload process. /// </summary> /// <param name="result">Contains the DC_ServerResponse that the server sent.</param> private void postFileStreamResult(IAsyncResult result) { PostFileStreamDelegate del = result.AsyncState as PostFileStreamDelegate; ServerConnectorResponse server_response = del.EndInvoke(result); if (!server_response.canceled) { upload_completed.Invoke(server_response); } }
/// <summary> /// Begin upload of a file to the server. /// </summary> /// <param name="file_location">Local file location on the client computer.</param> /// public void uploadFile(string file_location) { RequestQuery queue_query = new RequestQuery() { upload = true, file_location = file_location }; if (requestAlowed(queue_query) == false) { return; } FileStream fs = new FileStream(file_location, FileMode.Open, FileAccess.Read, FileShare.Read); Uri uri = buildUri("Files:upload"); PostFileStreamDelegate post = new PostFileStreamDelegate(postFileStream); post.BeginInvoke(uri, fs, new AsyncCallback(postFileStreamResult), post); }
/// <summary> /// Begin upload of a file to the server. /// </summary> /// <param name="file_location">Local file location on the client computer.</param> /// public void uploadFile(string file_location) { RequestQuery queue_query = new RequestQuery() { upload = true, file_location = file_location }; if(requestAlowed(queue_query) == false) return; FileStream fs = new FileStream(file_location, FileMode.Open, FileAccess.Read, FileShare.Read); Uri uri = buildUri("Files:upload"); PostFileStreamDelegate post = new PostFileStreamDelegate(postFileStream); post.BeginInvoke(uri, fs, new AsyncCallback(postFileStreamResult), post); }