Skip to content

Stream content as request content #2167

Description

@khchin93

I'm frustrated when i am using this library to upload a file to GCP Storage.

RestSharp 110.2.0 do have an method AddFile(parameterName, getFile, fileName, contentType) to supply a IO stream to body. However, RestSharp compose the request into multipart/formdata causes GCP Storage API to write the content into the file.
image

Using native .NET HttpClient allows me to compose the IO stream as stream content
var request = new HttpRequestMessage { Content = new StreamContent(sourceFileStream), };
which flawlessly achieved the goal.

And yes, I understand that using AddParameter(parameterName, rawByteArray, ParameterType.RequestBody) can achieve that, but when the byte array is too big, it going to eat up a lot of memory.

Therefore, allowing passing ContentStream as request content is really important.

Disclaimer:
I might missing some method in RestSharp to achieve that. Your help is much appreciated

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions