Esempio n. 1
0
        /// <summary>
        ///     Get a thumbnail for the given file
        /// </summary>
        /// <param name="dirEntry">The directory entry of the file</param>
        /// <param name="size">The size of the thumbnail (vertical and horizontal pixel count)</param>
        /// <returns></returns>
        public async Task <byte[]> GetThumbnailImage(SeafDirEntry dirEntry, int size)
        {
            dirEntry.ThrowOnNull(nameof(dirEntry));

            if (dirEntry.Type != DirEntryType.File)
            {
                throw new ArgumentException("The given directory entry is not a file.");
            }

            return(await GetThumbnailImage(dirEntry.LibraryId, dirEntry.Path, size));
        }
Esempio n. 2
0
        /// <summary>
        ///     Get a download link for the given file
        /// </summary>
        /// <param name="dirEntry">The directory entry for the file to download</param>
        /// <returns>The download link which is valid once</returns>
        public async Task <string> GetFileDownloadLink(SeafDirEntry dirEntry)
        {
            dirEntry.ThrowOnNull(nameof(dirEntry));

            if (dirEntry.Type != DirEntryType.File)
            {
                throw new ArgumentException("The given directory entry is not a file.");
            }

            return(await GetFileDownloadLink(dirEntry.LibraryId, dirEntry.Path));
        }
Esempio n. 3
0
        /// <summary>
        ///     Move the given file
        /// </summary>
        /// <param name="dirEntry">The directory entry of the file to move</param>
        /// <param name="targetLibrary">The library to move this file to</param>
        /// <param name="targetDirectory">The directory to move this file to</param>
        /// <returns>A value which indicates if the action was successful</returns>
        public async Task <bool> MoveFile(SeafDirEntry dirEntry, SeafLibrary targetLibrary, string targetDirectory)
        {
            dirEntry.ThrowOnNull(nameof(dirEntry));

            if (dirEntry.Type != DirEntryType.File)
            {
                throw new ArgumentException("The given directory entry is not a file.");
            }

            return(await MoveFile(dirEntry.LibraryId, dirEntry.Path, targetLibrary.Id, targetDirectory));
        }
Esempio n. 4
0
        /// <summary>
        ///     Rename the given file
        /// </summary>
        /// <param name="dirEntry">The directory entry of the file</param>
        /// <param name="newName">The new name of the file</param>
        /// <returns>A value which indicates if the action was successful</returns>
        public async Task <bool> RenameFile(SeafDirEntry dirEntry, string newName)
        {
            dirEntry.ThrowOnNull(nameof(dirEntry));

            if (dirEntry.Type != DirEntryType.File)
            {
                throw new ArgumentException("The given directory entry is not a file.");
            }

            return(await RenameFile(dirEntry.LibraryId, dirEntry.Path, newName));
        }
Esempio n. 5
0
        /// <summary>
        ///     Delete the given directory
        /// </summary>
        /// <param name="dirEntry">The directory to delete</param>
        /// <returns>A value which indicates if the action was successful</returns>
        public async Task <bool> DeleteDirectory(SeafDirEntry dirEntry)
        {
            dirEntry.ThrowOnNull(nameof(dirEntry));

            if (dirEntry.Type != DirEntryType.Dir)
            {
                throw new ArgumentException("The given directory entry is not a directory.");
            }

            return(await DeleteDirectory(dirEntry.LibraryId, dirEntry.Path));
        }
Esempio n. 6
0
        /// <summary>
        ///     Update the contents of the given, existing file
        /// </summary>
        /// <param name="dirEntry">The file to update</param>
        /// <param name="fileContent">The new content of the file</param>
        /// <param name="progressCallback">Optional progress callback (will report percentage of upload)</param>
        public async Task <bool> UpdateSingle(SeafDirEntry dirEntry, Stream fileContent, Action <float> progressCallback = null)
        {
            dirEntry.ThrowOnNull(nameof(dirEntry));
            fileContent.ThrowOnNull(nameof(fileContent));

            if (dirEntry.Type != DirEntryType.File)
            {
                throw new ArgumentException("The given dirEntry does not represent a file.");
            }

            return(await UpdateSingle(dirEntry.LibraryId, dirEntry.Directory, dirEntry.Name, fileContent, progressCallback));
        }
Esempio n. 7
0
        /// <summary>
        ///     Delete the given file
        /// </summary>
        /// <param name="dirEntry">Directory entry of the file to delete</param>
        /// <returns>A value which indicates if the deletion was successful</returns>
        public async Task <bool> DeleteFile(SeafDirEntry dirEntry)
        {
            dirEntry.ThrowOnNull(nameof(dirEntry));

            return(await DeleteFile(dirEntry.LibraryId, dirEntry.Path));
        }