Skip to content

mime/multipart library does not support setting content-type for individual fields #7130

@gopherbot

Description

@gopherbot

by jsgoecke:

This code:

file, err := os.Open("helloWorld.wav")
buf := new(bytes.Buffer)
writer := multipart.NewWriter(buf)
audioFile, _ := writer.CreateFormFile("file", "helloWorld.wav")
_, err = io.Copy(audioFile, file)
if err != nil {
     return nil, 0, err
}
writer.Close()

Produces a Content-Type of 'application/octet-stream' when it creates the field. There
are cases where you want to set the Content-Type to something like 'audio/wav' and other
types. You may do some things by hand like this as a work around:

http://play.golang.org/p/p5U_puIvkg

It would be appropriate to have the multipart library support setting the Content-Type
by individual form field.

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