Beispiel #1
0
        public async Task <HttpResponseMessage> GetResponseOfUploadAsync(string fileName, Stream fileStream)
        {
            fileName = TradeFileHelper.GetCorrectFileName(fileName);
            var fileContent = new ByteArrayContent(fileStream.GetByteArray());

            fileContent.Headers.ContentType        = MediaTypeHeaderValue.Parse("application/octet-stream");
            fileContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data")
            {
                FileName = fileName, Name = "content"
            };
            return(await _httpClient.PostAsync($"{_apiUploadUrl}{fileName}", new MultipartFormDataContent()
            {
                fileContent
            }));
        }
Beispiel #2
0
        public bool FileUpload(string fileName, Stream fileStream)
        {
            fileName = TradeFileHelper.GetCorrectFileName(fileName);
            var fileContent = new ByteArrayContent(fileStream.GetByteArray());

            fileContent.Headers.ContentType        = MediaTypeHeaderValue.Parse("application/octet-stream");
            fileContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data")
            {
                FileName = fileName, Name = "content"
            };
            var response = _httpClient.PostAsync($"{_apiUploadUrl}{fileName}", new MultipartFormDataContent()
            {
                fileContent
            }).Result;

            return(response.IsSuccessStatusCode);
        }