public IMegaRequest UploadStream(string targetNodeId, string name, long fileSize, Stream inputStream, Action <UploadHandle> OnHandleReady, Action <int> OnError) { if (fileSize == 0 || string.IsNullOrEmpty(targetNodeId) || inputStream == null || !inputStream.CanSeek) { if (OnError != null) { OnError(MegaApiError.EWRONG); } return(new EmptyRequest()); } var req = new MRequestGetUploadUrl <MResponseGetUploadUrl>(User, fileSize); UploadHandle handle = null; req.Success += (s, a) => { //Console.WriteLine("got url"); handle = MegaUploader.GetHandle(inputStream, name, fileSize, targetNodeId, a.Url); if (OnHandleReady != null) { Util.StartThread(() => OnHandleReady(handle), "transfer_handle_ready_handler"); } uploader.StartTransfer(handle); }; req.Error += (s, e) => { if (OnError != null) { OnError(e.Error); } }; transport.EnqueueRequest(req); return(req); }
public IMegaRequest UploadStream(string targetNodeId, string name, long fileSize, Stream inputStream, Action<UploadHandle> OnHandleReady, Action<int> OnError) { if (fileSize == 0 || string.IsNullOrEmpty(targetNodeId) || inputStream == null || !inputStream.CanSeek) { if (OnError != null) { OnError(MegaApiError.EWRONG); } return new EmptyRequest(); } var req = new MRequestGetUploadUrl<MResponseGetUploadUrl>(User, fileSize); UploadHandle handle = null; req.Success += (s, a) => { //Console.WriteLine("got url"); handle = MegaUploader.GetHandle(inputStream, name, fileSize, targetNodeId, a.Url); if (OnHandleReady != null) { Util.StartThread(()=> OnHandleReady(handle), "transfer_handle_ready_handler"); } uploader.StartTransfer(handle); }; req.Error += (s, e) => { if (OnError != null) { OnError(e.Error); } }; transport.EnqueueRequest(req); return req; }