我想知道在使用Post或PostAsync时实际传输了多少字节。我正在使用类似于以下的代码。我可以查看filePath的字节,但在我的实际代码中,我正在对读取和发送之间的文件流进行一些操作。如果你拿出MyFilteredContent
行,你会怎么做?
async Task<bool> SendFile(string filePath)
{
using (HttpContent fileContent = new FileContent(filePath))
using (MyFilteredContent filteredContent = new MyFilteredContent(fileContent))
{
var t = await MyAppSettings.TargetUrl
.AllowAnyHttpStatus()
.PostAsync(filteredContent);
if (t.IsSuccessStatusCode)
{
return true;
}
throw new Exception("blah blah");
}
}
答案 0 :(得分:0)
这是我在评论中描述的代码示例 - 使用DelegatingHandler,覆盖SendAsync以获取正在发送的请求的字节,然后配置FlurlHttp设置以使用处理程序:
one=1 2 and two=