Exemplo n.º 1
0
        private async Task <byte[]> DownloadTemplateFileContentAsync(TemplateDownloadInputDto input)
        {
            var postData = JsonSerializer.Serialize(input);

            using (var client = new CliHttpClient())
            {
                var responseMessage = await client.PostAsync(
                    $"{CliUrls.WwwAbpIo}api/download/template/",
                    new StringContent(postData, Encoding.UTF8, MimeTypes.Application.Json),
                    CancellationTokenProvider.Token
                    );

                if (!responseMessage.IsSuccessStatusCode)
                {
                    throw new Exception("Remote server returns error! HTTP status code: " + responseMessage.StatusCode);
                }

                return(await responseMessage.Content.ReadAsByteArrayAsync());
            }
        }
Exemplo n.º 2
0
        private async Task<byte[]> DownloadTemplateFileContentAsync(TemplateDownloadInputDto input)
        {
            var postData = JsonSerializer.Serialize(input);

            using (var client = new HttpClient())
            {
                client.Timeout = TimeSpan.FromMinutes(3);

                AddAuthentication(client);

                var responseMessage = await client.PostAsync(
                    Options.AbpIoWwwUrlRoot + "api/download/template/",
                    new StringContent(postData, Encoding.UTF8, MimeTypes.Application.Json),
                    CancellationTokenProvider.Token
                );

                if (!responseMessage.IsSuccessStatusCode)
                {
                    throw new Exception("Remote server returns error! HTTP status code: " + responseMessage.StatusCode);
                }

                return await responseMessage.Content.ReadAsByteArrayAsync();
            }
        }