Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http header info has been added into attachment content #84

Open
liaoyalien opened this issue Aug 22, 2017 · 3 comments
Open

http header info has been added into attachment content #84

liaoyalien opened this issue Aug 22, 2017 · 3 comments

Comments

@liaoyalien
Copy link

liaoyalien commented Aug 22, 2017

I use 3.0.0-beta-298 version to upload a blank text file as attachment to Zendesk.
It's was successfully uploaded. But when I open the file on Zendesk . I found the content was added additional digits as below pic.
It seems the http header has been added to the content.

zendeskuploadresult

I use the code this way....
foreach (IFormFile file in files)
{
Upload upload = await client.Attachments.UploadAsync(file.FileName, file.OpenReadStream());
if (upload != null)
{
AttachToken.Add(upload.Token);
}
}

@Jetski5822
Copy link
Contributor

Most weird, it seems like the issue is to do with the way the form encodes the data... I think the problem is this line

using (var content = new MultipartFormDataContent()) // hmm

Have you managed to find a work around?

@liaoyalien
Copy link
Author

Thank you to point this out. I'm not sure if below solution will work.
https://stackoverflow.com/questions/10339877/asp-net-webapi-how-to-perform-a-multipart-post-with-file-upload-using-webapi-ht

@liaoyalien
Copy link
Author

Hello~~ I found the root cause. replace line 57 to 63 to below.
It should be StreamContent rather than MultipartFormDataContent

using (var content = new StreamContent(inputStream)) { content.Headers.ContentType = new MediaTypeHeaderValue("application/binary"); return await client.PostAsync(requestUri, content).ConfigureAwait(false); }

@mikerogers123 mikerogers123 added this to To do in General maintenance via automation Jun 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

2 participants