Exemple #1
0
        /// <summary>
        /// Updates tags and stores if necessary
        /// </summary>
        /// <param name="connector">The API connector instance</param>
        /// <param name="fileData">Cloud File Data, including current tags (if any)</param>
        /// <param name="tagValues">list of tags to be stored</param>
        /// <returns>Update CloudFile</returns>
        public static async Task <CloudFile> SetTag(CloudElementsConnector connector, CloudFile fileData, List <string> tagValues)
        {
            bool mustStore = false;

            if (!connector.EndpointOptions.SupportsTags)
            {
                if (fileData.HasTags)
                {
                    fileData.tags = null;
                }
                return(fileData);
            }
            foreach (var tagItem in tagValues)
            {
                if (fileData.UpdateTag(tagItem))
                {
                    if (!mustStore)
                    {
                        mustStore = true;
                    }
                }
            }

            if (mustStore)
            {
                // store
                CloudElementsConnector.DirectoryEntryType deType = CloudElementsConnector.DirectoryEntryType.File;
                if (fileData.directory)
                {
                    deType = CloudElementsConnector.DirectoryEntryType.Folder;
                    throw new ArgumentException("CloudFile must point to a file; folders do not support tags");
                }
                CloudFile PatchData = new CloudFile();
                PatchData.id   = fileData.id;
                PatchData.tags = fileData.tags;
                fileData       = await connector.PatchDocEntryMetaData(deType, CloudElementsConnector.FileSpecificationType.ID, fileData.id, PatchData);
            }
            return(fileData);
        }
        /// <summary>
        /// Changes the name of a file (or folder)
        /// </summary>
        /// <param name="connector">The API connector instance</param>
        /// <param name="fileData">Cloud File Data</param>
        /// <param name="newFilename">new name</param>
        /// <returns>Updated CloudFile</returns>
        public static async Task <CloudFile> Rename(CloudElementsConnector connector, CloudFile targetFile, string newFilename)
        {
            if (newFilename.IndexOf("/") >= 0)
            {
                throw new ArgumentException("newFilename cannot include path information");
            }
            CloudElementsConnector.DirectoryEntryType deType = targetFile.EntryType;
            CloudFile PatchData = new CloudFile();

            PatchData.id   = targetFile.id;
            PatchData.name = newFilename;
            targetFile     = await connector.PatchDocEntryMetaData(deType, CloudElementsConnector.FileSpecificationType.ID, targetFile.id, PatchData);

            return(targetFile);
        }
Exemple #3
0
        /// <summary>
        /// Updates tags and stores if necessary
        /// </summary>
        /// <param name="connector">The API connector instance</param>
        /// <param name="fileData">Cloud File Data, including current tags (if any)</param>
        /// <param name="tagValue">tag to be stored</param>
        /// <returns>Update CloudFile</returns>
        public static async Task <CloudFile> SetTag(CloudElementsConnector connector, CloudFile fileData, string tagValue)
        {
            List <string> tagValues = new List <string>();

            tagValues.Add(tagValue);
            fileData = await SetTag(connector, fileData, tagValues);

            return(fileData);
        }