示例#1
0
        public async Task <HttpResponseMessage> InitializeUploadAsync(string filename, string fileSize)
        {
            _client.DefaultRequestHeaders.Add("Tus-Resumable", "1.0.0");
            _client.DefaultRequestHeaders.Add("Upload-Length", fileSize);

            var content = FileMetadata.AsHttpContent(filename: filename);

            return(await _client.PostAsync("documents/uploads", content));
        }
示例#2
0
        /// <summary>
        /// Moves a temporary file upload to its final destination and marks it as "submitted".
        /// Returns the file's name if the operation was successful.
        /// </summary>
        public async Task <string> FinalizeUploadAsync(Guid documentGuid, string destinationFolder)
        {
            var content  = FileMetadata.AsHttpContent(destinationFolder: destinationFolder);
            var response = await _client.PostAsync($"documents/uploads/{documentGuid}/submit", content);

            if (!response.IsSuccessStatusCode)
            {
                return(null);
            }

            return(await response.Content.ReadAsStringAsync());
        }