大家好,小弟后端用golang的grpc服务,前端把一个zip转成str传到后端 ,后端再转成byte 保存这个zip,但是无法打开这个zip,报错,说:
cannot find zipfile directory in one of test.zip or
test.zip.zip, and cannot find test.zip.ZIP, period.
我的代码如下:
func SaveWikiZip(fileData []byte, name string) bool {
fileName := fmt.Sprintf("%s%s.zip", tempFile, name)
err := ioutil.WriteFile(fileName, fileData, 0666)
if err != nil {
fmt.Println(err)
return false
}
return true
}
求问 如何把文件保存在本地还能打开 多谢
下面这种方式生成的zip文件是可以打开的,那应该就是你客户端上传和服务器下发过程中数据处理出了问题,这个过程是怎么样的?