安装又拍云官方的go-sdk
# 获取又拍云官方库 go get github.com/upyun/go-sdk/v3获取接口上传的文件
avatar, _, err := c.Request.FormFile("avatar")上传又拍云初始化
初始化又拍云服务,三个参数获取于又拍云后台
up := upyun.NewUpYun(&upyun.UpYunConfig{
Bucket: "Bucket",
Operator: "Operator",
Password: "Password",
})上传
上传:path为需要上传到又拍云的路径;avatar为获取的接口上传的文件
err = up.Put(&upyun.PutObjectConfig{
Path: path,
Reader: avatar,
})接口接口Content-type需为:multipart/form-data,上传类型为File
