/// <summary>根据HttpBuilder构建RequestRequest请求 /// </summary> public static IRestRequest BuildRequest(this HttpBuilder builder) { IRestRequest request = new RestRequest { Method = ParseMethod(builder.Method), Resource = builder.Resource.IsNullOrWhiteSpace() ? "" : builder.Resource }; foreach (var parameter in builder.Parameters) { var p = new RestSharp.Parameter() { Name = parameter.Name, Value = parameter.Value, DataFormat = parameter.DataFormat.ParseDataFormat(), ContentType = parameter.ContentType, Type = parameter.Type.ParseParameterType() }; request.AddParameter(p); } foreach (var file in builder.Files) { var f = new RestSharp.FileParameter() { Name = file.Name, FileName = file.FileName, ContentLength = file.ContentLength, ContentType = file.ContentType, Writer = file.Writer }; request.Files.Add(f); } return(request); }
private IRestRequest AddFile (FileParameter file) { Files.Add(file); return this; }
private IRestRequest AddFile(FileParameter file) { Files.Add(file); return(this); }
/// <summary> /// Adds the bytes to the Files collection with the specified file name /// </summary> /// <param name="name">The parameter name to use in the request</param> /// <param name="bytes">The file data</param> /// <param name="fileName">The file name to use for the uploaded file</param> /// <param name="contentType">The MIME type of the file to upload</param> /// <returns>This request</returns> public IRestRequest AddFile(string name, byte[] bytes, string fileName, string contentType = null) { return(AddFile(FileParameter.Create(name, bytes, fileName, contentType))); }
/// <summary> /// Adds the bytes to the Files collection with the specified file name /// </summary> /// <param name="name">The parameter name to use in the request</param> /// <param name="bytes">The file data</param> /// <param name="fileName">The file name to use for the uploaded file</param> /// <returns>This request</returns> public IRestRequest AddFile(string name, byte[] bytes, string fileName) { return(AddFile(FileParameter.Create(name, bytes, fileName))); }
private IRestRequest AddFile(FileParameter file) { return(this.With(x => x.Files.Add(file))); }
private IRestRequest AddFile(FileParameter file) { this.Files.Add(file); return this; }