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

Open
Chrestkoo opened this issue Jan 13, 2022 · 4 comments
Open

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

Chrestkoo opened this issue Jan 13, 2022 · 4 comments

Comments

@Chrestkoo
Copy link

@Chrestkoo Chrestkoo commented Jan 13, 2022

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
Contributor

@seankhliao seankhliao commented Jan 13, 2022

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

@Chrestkoo Chrestkoo commented Jan 13, 2022

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
Copy link
Contributor

@seankhliao seankhliao commented Jan 13, 2022

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

@Chrestkoo
Copy link
Author

@Chrestkoo Chrestkoo commented Jan 13, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants