fix(wxapi): 修复潜在的内存泄漏问题

This commit is contained in:
Fu Diwei
2021-08-05 20:42:01 +08:00
parent 5470783813
commit 5a6f445c61
3 changed files with 6 additions and 6 deletions

View File

@@ -357,8 +357,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
.SetQueryParam("access_token", request.AccessToken);
string boundary = "--BOUNDARY--" + DateTimeOffset.Now.Ticks.ToString("x");
var httpContent = new MultipartFormDataContent(boundary);
var fileContent = new ByteArrayContent(request.FileBytes ?? new byte[0]);
using var httpContent = new MultipartFormDataContent(boundary);
using var fileContent = new ByteArrayContent(request.FileBytes ?? new byte[0]);
httpContent.Add(fileContent, "\"pdf\"", "\"invoice.pdf\"");
httpContent.Headers.ContentType = MediaTypeHeaderValue.Parse("multipart/form-data; boundary=" + boundary);
fileContent.Headers.ContentType = MediaTypeHeaderValue.Parse("application/pdf");

View File

@@ -45,8 +45,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
.SetQueryParam("width", request.Width);
string boundary = "--BOUNDARY--" + DateTimeOffset.Now.Ticks.ToString("x");
var httpContent = new MultipartFormDataContent(boundary);
var fileContent = new ByteArrayContent(request.ImageFileBytes ?? new byte[0]);
using var httpContent = new MultipartFormDataContent(boundary);
using var fileContent = new ByteArrayContent(request.ImageFileBytes ?? new byte[0]);
httpContent.Add(fileContent, "\"media\"", "\"image.png\"");
httpContent.Headers.ContentType = MediaTypeHeaderValue.Parse("multipart/form-data; boundary=" + boundary);
fileContent.Headers.ContentType = MediaTypeHeaderValue.Parse("image/png");

View File

@@ -31,8 +31,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
.SetQueryParam("access_token", request.AccessToken);
string boundary = "--BOUNDARY--" + DateTimeOffset.Now.Ticks.ToString("x");
var httpContent = new MultipartFormDataContent(boundary);
var fileContent = new ByteArrayContent(request.ImageFileBytes ?? new byte[0]);
using var httpContent = new MultipartFormDataContent(boundary);
using var fileContent = new ByteArrayContent(request.ImageFileBytes ?? new byte[0]);
httpContent.Add(fileContent, "\"media\"", "\"image.png\"");
httpContent.Headers.ContentType = MediaTypeHeaderValue.Parse("multipart/form-data; boundary=" + boundary);
fileContent.Headers.ContentType = MediaTypeHeaderValue.Parse("image/png");