根本原因:
https://blog.csdn.net/weixin_44537122/article/details/105072423
解决方法:
java
https://blog.csdn.net/weianswer/article/details/106651673
golang
//上传文件流
func UploadFileByte(bucketName string, objectName string, localFileName multipart.File) (msg string, err error) {
fmt.Printf("上传文件流...")
bucket, err := NewOSSClient(bucketName)
if err != nil {
return "OSS实例创建失败", err
}
//将ContentType设为image/jpg,这样访问url不会自动下载
option :=oss.ContentType("image/jpg")
err = bucket.PutObject(objectName, localFileName, option)
if err != nil {
panic(err)
return "上传失败", err
}
return "上传成功", err
}
有疑问加站长微信联系(非本文作者)