I was using AdvancedResponseWriter as shown in code below in order to save incoming stream in file. But in the new version of RestSharp the method changed it’s signature to get Func <HttpResponseMessage message, RestRequest request, RestResponse restResponse>
How should I change my code in order to use new signature?
string fileName = ...;
Uri url = ...;
var restRequest = new RestRequest
{
Method = Method.Get,
AdvancedResponseWriter = (Stream data, IHttpResponse http) =>
{
var contentType = http.ContentType;
if (string.IsNullOrEmpty(contentType) || contentType.Equals(OctetStreamContentType, StringComparison.OrdinalIgnoreCase))
{
contentType = MimeTypes.GetMimeType(GetFileName(fileName, url, OctetStreamContentType));
}
filePath = this.fileSystem.Path.Combine(this.fileSystem.Path.GetTempPath(), $"{connectorId}", GetFileName(fileName, url, contentType));
this.fileSystem.Directory.CreateDirectory(this.fileSystem.Path.GetDirectoryName(filePath));
var copySuccess = false;
using (var file = this.fileSystem.File.OpenWrite(filePath))
{
copySuccess = data.CopyToWithLimit(file, sizeLimit); // copies the data stream to file stream
}
if (!copySuccess)
{
...
}
},
}
.AddHeader(AcceptHeader, AcceptHeaderValue);