Пример #1
0
        private void FinishFile(UploadHandle handle, string uploadHandle)
        {
            handle.Mac = new byte[16];
            foreach (var chunk in handle.Chunks)
            {
                handle.Mac = handle.Mac.Xor(chunk.Mac);
                handle.Mac = Crypto.Encrypt(handle.AesAlg, handle.Mac);
            }
            PrepareNodeKeys(handle);
            var node = new MegaNode
            {
                Id         = uploadHandle,
                ParentId   = handle.UploadTargetNode,
                Type       = MegaNodeType.File,
                Attributes = new NodeAttributes {
                    Name = handle.Name
                },
                NodeKey = new NodeKeys(handle.NodeKeys, User)
            };
            var r = new MRequestCompleteUpload <MResponseCompleteUpload>(User, node);

            //Console.WriteLine("Sending finish request");
            r.Success += (s, a) =>
            {
                handle.Node = a.NewNode.FirstOrDefault();
                handle.EndTransfer(null);
            };
            r.Error += (s, a) =>
            {
                handle.EndTransfer(a.Error);
            };
            transport.EnqueueRequest(r);
        }
Пример #2
0
 private void FinishFile(UploadHandle handle, string uploadHandle)
 {
     handle.Mac = new byte[16];
     foreach (var chunk in handle.Chunks)
     {
         handle.Mac = handle.Mac.Xor(chunk.Mac);
         handle.Mac = Crypto.Encrypt(handle.AesAlg, handle.Mac);
     }
     PrepareNodeKeys(handle);
     var node = new MegaNode
     {
         Id = uploadHandle,
         ParentId = handle.UploadTargetNode,
         Type = MegaNodeType.File,
         Attributes = new NodeAttributes { Name = handle.Name },
         NodeKey = new NodeKeys(handle.NodeKeys, User)
     };
     var r = new MRequestCompleteUpload<MResponseCompleteUpload>(User, node);
     //Console.WriteLine("Sending finish request");
     r.Success += (s, a) =>
     {
         handle.Node = a.NewNode.FirstOrDefault();
         handle.EndTransfer(null);
     };
     r.Error += (s, a) =>
     {
         handle.EndTransfer(a.Error);
     };
     transport.EnqueueRequest(r);
 }