Пример #1
0
        public async Task <Node> CreateFolder(string name, Node parent, CancellationToken cancellationToken)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name");
            }

            if (parent == null)
            {
                throw new ArgumentNullException("parent");
            }

            if (parent.Type == NodeType.File)
            {
                throw new ArgumentException("Invalid parent node");
            }

            //this.EnsureLoggedIn();
            var key = Crypto.CreateAesKey();

            byte[] attributes   = EncryptAttributes(new Attributes(name), key);
            byte[] encryptedKey = Crypto.EncryptAes(key, this._masterKey);

            CreateNodeRequest request  = CreateNodeRequest.CreateFolderNodeRequest(parent, attributes.ToBase64(), encryptedKey.ToBase64());
            GetNodesResponse  response = await Post <CreateNodeRequest, GetNodesResponse>(request, cancellationToken);

            var node = response.Nodes[0];

            DecriptNode(node, response);
            return(node);
        }