RestSharp๋ก ๋์ฉ๋ ํ์ผ์ ์ ๋ก๋ํ ๋ ๋ฌด์์๋ก OutOfMemory ๋ฌธ์ ๊ฐ ๋ฐ์ํฉ๋๋ค. ์ด๊ฒ์ RestSharp๊ฐ ์ฅ๋ฉด ๋ค์์ HttpWebRequest๋ฅผ ์ฌ์ฉํ๊ณ ์๊ณ AllowWriteStreamBuffering์ ๊ธฐ๋ณธ๊ฐ์ด true์ด๊ธฐ ๋๋ฌธ์ ๋ฐ์ํฉ๋๋ค. ์ด๋ ์ฟผ๋ฆฌ๋ฅผ ์ํํ ๋ ์ ์ฒด ํ์ผ์ด ๋ฉ๋ชจ๋ฆฌ์ ๋ก๋๋จ์ ์๋ฏธํฉ๋๋ค. ๊ทธ๋ฌ๋ 500MB ํ์ผ์ ์ ๋ก๋ํ๋ ๊ฒฝ์ฐ ๋ฌธ์ ๊ฐ ๋ฉ๋๋ค.
ํ์ํ ๊ฒ์ AllowWriteStreamBuffering์ false๋ก ์ค์ ํ๋ ๊ฒ์ด์ง๋ง ์ง๊ธ ๋น์ฅ์ ConfigureWebRequest์์ AllowWriteStreamBuffering์ ๋ณ๊ฒฝํ ๋ฐฉ๋ฒ์ด ์์ต๋๋ค.
๋ค์๊ณผ ๊ฐ์ ๊ฒ์ด ์ฐ๋ฆฌ์ ํ์์ ์ถฉ๋ถํ ๊ฒ์ ๋๋ค.
var request = new RestRequest(Method.POST);
request.AllowWriteStreamBuffering = false;
request.Files.Add(new FileParameter // ...
์ฐธ๊ณ : .Net๊ณผ RestSharp 105.2.3์ ๋ฉ๋ชจ๋ฆฌ ์๋ ฅ์ ํ ์คํธํ ์ ์๋๋ก .AddFile์ ์ฌ์ฉํ ๋ ๋ฆด๋ฆฌ์ค๋์ง ์์ ๋ฒ๊ทธ ์์ ์ด ์์ผ๋ฏ๋ก ํ ์คํธ ๋ฐฉ๋ฒ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
// In the current implementation of RestSharp, there is an issue when using AddFile with a writer.
// It doesn't set the ContentLength, which break the queries with System.Net.ProtocolViolationException as we are not uploading
// the expected amount of bytes. It's fixed in an yet unreleased version, so we are using the Files.Add manually for now.
var request = new RestRequest(Method.POST);
request.Files.Add(new FileParameter
{
Name = "file",
Writer = outStream => inStream.CopyTo(outStream),
FileName = fileName,
ContentLength = inStream.Length,
});
์ด์ ๋ํ ์ ๋ฐ์ดํธ๊ฐ ์์ต๋๊น? ๋๋ ์ ํํ ๊ฐ์ ๋ฌธ์ ๋ฅผ ๊ฒช๊ณ ์์ผ๋ฉฐ RestClient ๋๋ RestRequest์์ AllowWriteStreamBuffering์ ๋ ธ์ถํ๋ ๊ฒ์ด ํฉ๋ฆฌ์ ์ผ๋ก ๋ณด์ ๋๋ค. ๋ด๊ฐ ์๋ ํ ํด๊ฒฐ ๋ฐฉ๋ฒ์ด ์์ต๋๋ค. ๋ด ์ ์ค ์ผ์ด์ค๋ ๋ณ๋ ฌ 100MB ํ์ผ์ ๋ณด๋ด๊ณ AllowWriteStreamBuffering์ด true์ด๋ฉด ๋ฉ๋ชจ๋ฆฌ ๋ถ์กฑ ์์ธ๊ฐ ๋งค์ฐ ์์ฃผ ๋ฐ์ํฉ๋๋ค.
๋์ผํ ๋ฌธ์ ๊ฐ ๋ฐ์ํ๊ณ ์ฒ๋ฆฌ ๋ฐฉ๋ฒ์ด ์์ต๋๋ค.
์์ง ํด๊ฒฐ๋๋์????
@AgentCoolDevil ๋์์ฃผ์๊ฒ ์ต๋๊น? ํ ๋ฆฌํ์คํธ๋ฅผ ํฉ๋๋ค.
์ต์ ๋ฒ์ ์์ ์ฌ์ ํ ์ด ์ค๋ฅ๊ฐ ๋ฐ์ํ๋ ์ฌ๋์ด ์์ต๋๊น?
@yvesmh ๊ฐ #1213์์ ์ ๋นํ๊ฒ ์ธ๊ธํ๋ฏ์ด ์ด ๋ฌธ์ ๋ WebRequest
์ฐ๊ธฐ ์คํธ๋ฆผ ๋ฒํผ๋ง์ ๋นํ์ฑํํ์ฌ ํด๊ฒฐํ ์ ์์ต๋๋ค. IRestClient
์์ ์น ์์ฒญ ๊ตฌ์ฑ์ ์ฌ์ฉํ์ฌ ์ด๋ฌํ ๊ฒฝ์ฐ๋ฅผ ์ฒ๋ฆฌํ ์ ์์ต๋๋ค.
client.ConfigureWebRequest(x => x.AllowWriteStreamBuffering = false);
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
๋์ผํ ๋ฌธ์ ๊ฐ ๋ฐ์ํ๊ณ ์ฒ๋ฆฌ ๋ฐฉ๋ฒ์ด ์์ต๋๋ค.