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

feat(mime): Add Custom content-type for MultipartWriter #960

Merged
merged 3 commits into from
Jun 15, 2021

Conversation

getspooky
Copy link
Contributor

It's good idea to specify custom headers:

const buf = new Buffer();
const mw = new MultipartWriter(buf);
await mw.writeField("foo", "foo");
await mw.writeField("bar", "bar");
const f = await Deno.open(path.join(testdataDir, "sample.txt"), {
    read: true,
 });
const header = new Headers();
header.set("deno", "deno");
await mw.writeFile("file", "sample.txt", f, header);
await mw.close();
f.close();

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what the "createPart" method is for?

@getspooky
Copy link
Contributor Author

getspooky commented Jun 10, 2021

createPart is private method. i don't think there is a way to pass custom header ?
I think possible solution is to pass custom headers from createFormFile to createPart .

@getspooky getspooky requested a review from ry June 10, 2021 10:44
@ry
Copy link
Member

ry commented Jun 10, 2021

@getspooky Have a look at the Go version of this module, from which this is based: https://golang.org/pkg/mime/multipart/#Writer.CreatePart
https://golang.org/pkg/mime/multipart/#Writer.WriteField
The signatures here should match those in Go. So it seems like createPart should be public.

Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kt3k kt3k merged commit f898e38 into denoland:main Jun 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants