[code]//oss上传func (c *BaseController) OssUploadImg(picName string) (string, error) {//获取上传的文件f, h, err := c.GetFile(picName)if err != nil {return \"\", err}//关闭文件流defer f.Close()//3.获取后缀名,判断类型是否正确 .jpg .png .gif .jpegextName := path.Ext(h.Filename)allowExtMap := map[string]bool{\".jpg\": true,\".png\": true,\".gif\": true,\".jpeg\": true,}if _, ok := allowExtMap[extName]; !ok {return \"\", errors.New(\"图片后缀名不合法\")}// 创建OSSClient实例。client, err := oss.New(\"你的endpoint\", \"你的accessKeyID\", \"你的accesskeySecret\")if err != nil {return \"\", err}// 获取存储空间。bucket, err := client.Bucket(\"你的bucketName\")if err != nil {fmt.Println(\"Error:\", err)os.Exit(-1)}day := time.Now().Format(\"20060102\")dir := \"static/upload\" + day//5.生成文件名称fileUnixName := strconv.FormatInt(time.Now().Unix(), 10)saveDir := path.Join(dir, fileUnixName+extName)// 上传文件流。err = bucket.PutObject(saveDir, f)fmt.Println(err, \"上传错误\")if err != nil {return \"\", err}return saveDir, nil}