Пример #1
0
        internal static HttpContent CreateFileContent(IRestClient client, IRequestFile file, bool inMultipart = false)
        {
            HttpContent content = new StreamContent(file.Content, file.BufferSize);

            content.Headers.ContentLength = file.Content.Length;

            if (!String.IsNullOrEmpty(file.ContentType))
            {
                content.Headers.ContentType = MediaTypeHeaderValue.Parse(file.ContentType);
            }
            else if (client.Settings.ContentTypeProvider != null && !String.IsNullOrEmpty(file.FileName))
            {
                string contentType;
                if (client.Settings.ContentTypeProvider.TryGetContentType(file.FileName, out contentType))
                {
                    content.Headers.ContentType = MediaTypeHeaderValue.Parse(contentType);
                }
            }

            if (!inMultipart)
            {
                var multipart = new MultipartFormDataContent();
                multipart.Add(content, file.Name, file.FileName);
                content = multipart;
            }

            return(content);
        }
 public bool TryGetValue(string key, out IRequestFile value)
 {
     return this.Memo.TryGetValue(key, out value);
 }
 public bool TryGetValue(string key, out IRequestFile value)
 {
     return(this.Memo.TryGetValue(key, out value));
 }
Пример #4
0
 public Task <string> UploadFileAsync(IRequestFile file, [RequestForm] string name)
 {
     throw new NotImplementedException();
 }
Пример #5
0
 public Task <string> UploadFilesAsync(IRequestFile file1, IRequestFile file2, IRequestFile file3)
 {
     throw new NotImplementedException();
 }
Пример #6
0
 public Task <string> UploadFileAsync(IRequestFile file, TestServiceParam param)
 {
     throw new NotImplementedException();
 }
Пример #7
0
 public static IRequestBuilder WithFile(this IRequestBuilder builder, IRequestFile file)
 {
     return(builder.With(file));
 }
Пример #8
0
 public FeignClientFileRequestContent(string name, IRequestFile requestFile)
 {
     Name        = name;
     RequestFile = requestFile;
 }