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

mime/multipart: CreateFormFile defaults content-type to application/octet-stream #30218

Closed
melissafzhang opened this issue Feb 13, 2019 · 7 comments

Comments

@melissafzhang
Copy link

melissafzhang commented Feb 13, 2019

What version of Go are you using (go version)?

$ go version 1.11.5

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/melissazhang/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/melissazhang/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.11.5/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.11.5/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/melissazhang/src/babel-fish/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/bx/54d6qfbs7g19jps4b60rnkq00000gp/T/go-build334342869=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

createFormFile always defaults content type to application/octet-stream which is not always the case.

What did you expect to see?

Should allow you to customize or it should detect the content type

What did you see instead?

Defaults to application/octet-stream

@ianlancetaylor
Copy link
Contributor

You can use CreatePart which lets you customize it however you like. CreateFormField is a convenience function. (And I don't see where CreateFormField sets the Content-Type at all.)

@melissafzhang
Copy link
Author

@ianlancetaylor
Copy link
Contributor

That is CreateFormFile. You filed this bug against CreateFormField.

@melissafzhang melissafzhang changed the title mime/multipart: CreateFormField defaults content-type to application/octet-stream mime/multipart: CreateFormFile defaults content-type to application/octet-stream Feb 14, 2019
@melissafzhang
Copy link
Author

@ianlancetaylor nice catch! updated

@ianlancetaylor
Copy link
Contributor

OK. But it's still true that CreateFormFile is just a simple wrapper around CreatePart. We can't really change CreateFormFile without breaking the Go 1 compatibility guarantee (https://golang.org/doc/go1compat).

@katiehockman
Copy link
Contributor

/cc @bradfitz just in case you want to weigh in. It sounds like this should be closed, based on the feedback from @ianlancetaylor on this issue.

@katiehockman katiehockman added this to the Unplanned milestone Feb 15, 2019
@bradfitz
Copy link
Contributor

Yeah, I agree with Ian. We can't break compatibility and it's already possible to set other content-types with the other methods.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants