Skip to content

net/http: FormFile size different from original zip file #50593

Closed
@Chrestkoo

Description

@Chrestkoo

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

$ go version golang:1.17.5
$ docker image: golang:1.17.5-stretch

Does this issue reproduce with the latest release?

Don't know.

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

go env Output
$ go env

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/gcc/.cache/go-build"
GOENV="/home/gcc/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17.5"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2669985125=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Use Postman to call created api. Code only retrieve post form file value of the api. The file is zip file.
So far it is just happend on receiving zip file. Text file is tried and no issue.

func HandleAddTranslationResourcesFileReqTest(w http.ResponseWriter, req *http.Request) err {
	if err := req.ParseMultipartForm(32 << 20); err != nil {
		return err
	}

	file, header, err := req.FormFile("transSourceFile")
	if err != nil {
		return err
	}
	defer file.Close()
	fmt.Println("header.Size:", header.Size)
        return nil
}

What did you expect to see?

Expect to see the same zip file size [header.Size] with origin file.

What did you see instead?

I see different zip file size [header.Size] with origin file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeWaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions