codeskyblue / gohttpserver

The best HTTP Static File Server, write with golang+vue
MIT License
2.57k stars 541 forks source link

文件过大上传失败 #98

Closed mamidemima closed 3 years ago

mamidemima commented 4 years ago

文件过大上传失败,亲测群辉在docker下部署 发现31M的压缩文件上传可以!大一点的34.5M就不行

codeskyblue commented 4 years ago

NAS? 有没有错误日志?

在2020年10月19日 11:20,mamidemima 写道: 文件过大上传失败,亲测群辉在docker下部署 发现31M的压缩文件上传可以!大一点的34.5M就不行

—You are receiving this because you are subscribed to this thread.Reply to this email directly, view it on GitHub, or unsubscribe. [ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/codeskyblue/gohttpserver/issues/98", "url": "https://github.com/codeskyblue/gohttpserver/issues/98",

"name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ]

qiuyuzhou commented 4 years ago

@mamidemima Fix in #99 因为在k8s环境下/tmp和/app/public目录不是同一个硬盘。而大于32M,系统库会把文件先存到/tmp下,而原作者使用os.Rename去移动文件。而且错误没有正确处理,本来是会报500错误,结果panic了。

10-5 commented 4 years ago

同样的问题. 相关日志如下:

2020/10/23 21:19:52 httpstaticserver.go:239: Move /tmp/multipart-153265978 -> /app/public/xxx.zip
2020/10/23 21:19:52 httpstaticserver.go:252: Handle upload file: <nil>
2020/10/23 21:19:52 server.go:3085: http: panic serving 172.20.0.5:53218: runtime error: invalid memory address or nil pointer dereference
goroutine 137 [running]:
net/http.(*conn).serve.func1(0xc000290000)
        /usr/local/go/src/net/http/server.go:1795 +0x139
panic(0x933ee0, 0xe2afd0)
        /usr/local/go/src/runtime/panic.go:679 +0x1b2
main.(*HTTPStaticServer).hUploadOrMkdir(0xc000156480, 0xa96a40, 0xc00015c0b0, 0xc00011ab00)
        /app/gohttpserver/httpstaticserver.go:253 +0x680
net/http.HandlerFunc.ServeHTTP(0xc000147530, 0xa96a40, 0xc00015c0b0, 0xc00011ab00)
        /usr/local/go/src/net/http/server.go:2036 +0x44
github.com/gorilla/mux.(*Router).ServeHTTP(0xc00015e150, 0xa96a40, 0xc00015c0b0, 0xc00011ab00)
        /go/pkg/mod/github.com/gorilla/mux@v1.6.2/mux.go:162 +0x104
main.(*HTTPStaticServer).ServeHTTP(0xc000156480, 0xa96a40, 0xc00015c0b0, 0xc00011a900)
        /app/gohttpserver/httpstaticserver.go:97 +0x50
github.com/codeskyblue/go-accesslog.(*LoggingHandler).ServeHTTP(0xc000145d40, 0xa97140, 0xc0001bc0e0, 0xc00011a900)
        /go/pkg/mod/github.com/codeskyblue/go-accesslog@v0.0.0-20171215023101-6188d3bd9371/accesslog.go:162 +0x3cf
net/http.(*ServeMux).ServeHTTP(0xe3d320, 0xa97140, 0xc0001bc0e0, 0xc00011a900)
        /usr/local/go/src/net/http/server.go:2416 +0x1bd
net/http.serverHandler.ServeHTTP(0xc0001bc2a0, 0xa97140, 0xc0001bc0e0, 0xc00011a900)
        /usr/local/go/src/net/http/server.go:2831 +0xa4
net/http.(*conn).serve(0xc000290000, 0xa98600, 0xc000078040)
        /usr/local/go/src/net/http/server.go:1919 +0x875
created by net/http.(*Server).Serve
        /usr/local/go/src/net/http/server.go:2957 +0x384
phoenixwu0229 commented 3 years ago

同样的问题. 相关日志如下:

2020/10/23 21:19:52 httpstaticserver.go:239: Move /tmp/multipart-153265978 -> /app/public/xxx.zip
2020/10/23 21:19:52 httpstaticserver.go:252: Handle upload file: <nil>
2020/10/23 21:19:52 server.go:3085: http: panic serving 172.20.0.5:53218: runtime error: invalid memory address or nil pointer dereference
goroutine 137 [running]:
net/http.(*conn).serve.func1(0xc000290000)
        /usr/local/go/src/net/http/server.go:1795 +0x139
panic(0x933ee0, 0xe2afd0)
        /usr/local/go/src/runtime/panic.go:679 +0x1b2
main.(*HTTPStaticServer).hUploadOrMkdir(0xc000156480, 0xa96a40, 0xc00015c0b0, 0xc00011ab00)
        /app/gohttpserver/httpstaticserver.go:253 +0x680
net/http.HandlerFunc.ServeHTTP(0xc000147530, 0xa96a40, 0xc00015c0b0, 0xc00011ab00)
        /usr/local/go/src/net/http/server.go:2036 +0x44
github.com/gorilla/mux.(*Router).ServeHTTP(0xc00015e150, 0xa96a40, 0xc00015c0b0, 0xc00011ab00)
        /go/pkg/mod/github.com/gorilla/mux@v1.6.2/mux.go:162 +0x104
main.(*HTTPStaticServer).ServeHTTP(0xc000156480, 0xa96a40, 0xc00015c0b0, 0xc00011a900)
        /app/gohttpserver/httpstaticserver.go:97 +0x50
github.com/codeskyblue/go-accesslog.(*LoggingHandler).ServeHTTP(0xc000145d40, 0xa97140, 0xc0001bc0e0, 0xc00011a900)
        /go/pkg/mod/github.com/codeskyblue/go-accesslog@v0.0.0-20171215023101-6188d3bd9371/accesslog.go:162 +0x3cf
net/http.(*ServeMux).ServeHTTP(0xe3d320, 0xa97140, 0xc0001bc0e0, 0xc00011a900)
        /usr/local/go/src/net/http/server.go:2416 +0x1bd
net/http.serverHandler.ServeHTTP(0xc0001bc2a0, 0xa97140, 0xc0001bc0e0, 0xc00011a900)
        /usr/local/go/src/net/http/server.go:2831 +0xa4
net/http.(*conn).serve(0xc000290000, 0xa98600, 0xc000078040)
        /usr/local/go/src/net/http/server.go:1919 +0x875
created by net/http.(*Server).Serve
        /usr/local/go/src/net/http/server.go:2957 +0x384

你这个有解决吗?

10-5 commented 3 years ago

同样的问题. 相关日志如下:

2020/10/23 21:19:52 httpstaticserver.go:239: Move /tmp/multipart-153265978 -> /app/public/xxx.zip
2020/10/23 21:19:52 httpstaticserver.go:252: Handle upload file: <nil>
2020/10/23 21:19:52 server.go:3085: http: panic serving 172.20.0.5:53218: runtime error: invalid memory address or nil pointer dereference
goroutine 137 [running]:
net/http.(*conn).serve.func1(0xc000290000)
        /usr/local/go/src/net/http/server.go:1795 +0x139
panic(0x933ee0, 0xe2afd0)
        /usr/local/go/src/runtime/panic.go:679 +0x1b2
main.(*HTTPStaticServer).hUploadOrMkdir(0xc000156480, 0xa96a40, 0xc00015c0b0, 0xc00011ab00)
        /app/gohttpserver/httpstaticserver.go:253 +0x680
net/http.HandlerFunc.ServeHTTP(0xc000147530, 0xa96a40, 0xc00015c0b0, 0xc00011ab00)
        /usr/local/go/src/net/http/server.go:2036 +0x44
github.com/gorilla/mux.(*Router).ServeHTTP(0xc00015e150, 0xa96a40, 0xc00015c0b0, 0xc00011ab00)
        /go/pkg/mod/github.com/gorilla/mux@v1.6.2/mux.go:162 +0x104
main.(*HTTPStaticServer).ServeHTTP(0xc000156480, 0xa96a40, 0xc00015c0b0, 0xc00011a900)
        /app/gohttpserver/httpstaticserver.go:97 +0x50
github.com/codeskyblue/go-accesslog.(*LoggingHandler).ServeHTTP(0xc000145d40, 0xa97140, 0xc0001bc0e0, 0xc00011a900)
        /go/pkg/mod/github.com/codeskyblue/go-accesslog@v0.0.0-20171215023101-6188d3bd9371/accesslog.go:162 +0x3cf
net/http.(*ServeMux).ServeHTTP(0xe3d320, 0xa97140, 0xc0001bc0e0, 0xc00011a900)
        /usr/local/go/src/net/http/server.go:2416 +0x1bd
net/http.serverHandler.ServeHTTP(0xc0001bc2a0, 0xa97140, 0xc0001bc0e0, 0xc00011a900)
        /usr/local/go/src/net/http/server.go:2831 +0xa4
net/http.(*conn).serve(0xc000290000, 0xa98600, 0xc000078040)
        /usr/local/go/src/net/http/server.go:1919 +0x875
created by net/http.(*Server).Serve
        /usr/local/go/src/net/http/server.go:2957 +0x384

你这个有解决吗?

没有解决,暂时转用其他方法上传了。

bGZo commented 1 year ago

很抱歉打擾到您。

我想補充一個用例:當我關閉 iPhone 的 shadowRocket 後,我上傳成功了,之前上傳小文件(如圖片都是可以的),唯獨像壓縮包/PDF之類較大的文件不行,一直都是 Server responded with 0 code 的狀態,無關瀏覽器,测试用 Chrome/Safari 也是如此。而 Android 沒有發現這個問題。

希望能幫到您。