Example #1
0
        /// <summary>
        ///     Retrieve a link to upload files for the given library
        /// </summary>
        /// <param name="libraryId">The id of the library the file should be uploaded to</param>
        public async Task <string> GetUploadLink(string libraryId)
        {
            libraryId.ThrowOnNull(nameof(libraryId));

            // to upload files we need to get an upload link first
            var request = new GetUploadLinkRequest(AuthToken, libraryId);

            return(await _webConnection.SendRequestAsync(ServerUri, request));
        }
Example #2
0
        /// <summary>
        ///     Uploads a single file
        ///     Does not replace already existing files, instead the file will be renamed (e.g. test(1).txt if test.txt already
        ///     exists)
        ///     Use UpdateSingle to replace the contents of an already existing file
        /// </summary>
        /// <param name="libraryId">The id of the library the file should be uploaded to</param>
        /// <param name="targetDirectory">The directory the file should be uploaded to</param>
        /// <param name="targetFilename">The name of the file</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> UploadSingle(string libraryId, string targetDirectory, string targetFilename, Stream fileContent, Action <float> progressCallback = null)
        {
            // to upload files we need to get an upload link first
            var req        = new GetUploadLinkRequest(AuthToken, libraryId);
            var uploadLink = await _webConnection.SendRequestAsync(ServerUri, req);

            var uploadRequest = new UploadFilesRequest(AuthToken, uploadLink, targetDirectory, targetFilename, fileContent, progressCallback);

            return(await _webConnection.SendRequestAsync(ServerUri, uploadRequest));
        }