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

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

Closed
Chrestkoo opened this issue Jan 13, 2022 · 5 comments
Closed

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

Chrestkoo opened this issue Jan 13, 2022 · 5 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@Chrestkoo
Copy link

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.

@seankhliao seankhliao changed the title affected/package: net/http: FormFile size different from original zip file Jan 13, 2022
@seankhliao
Copy link
Member

what's the actual difference you see?
have you verified that the complete file was uploaded?
what's the difference between the file contents you get and the file you sent?

@Chrestkoo
Copy link
Author

i had compare uploaded file and origin file.
the comparison result as the 1drv.ms/u/s!ApOAtDwy99qQ9mMnjoPa-iKdXEIg?e=DLK3Ug
the zip file and generated file as in https://1drv.ms/u/s!ApOAtDwy99qQ9ma_VcldR7TOGtmU?e=5xg7Ez

This case only happend in server and zip file. My local M1 Macbook Pro does not have this issue.

@seankhliao seankhliao added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jan 13, 2022
@seankhliao
Copy link
Member

Seems like something else is interfering with your request.
Not much we can do about that

@Chrestkoo
Copy link
Author

I have no idea on this and I know this case does not happen on non-zip file. I suspect development environment is the cause.

@seankhliao
Copy link
Member

Given that this seems likely to be a local environment issue, I'm going to close this for now. Feel free file a new one if you believe it's an error in net/http and have a reproducer for it.

@golang golang locked and limited conversation to collaborators Feb 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

3 participants