修改为大写
This commit is contained in:
+8
-8
@@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/aliyun/aliyun-oss-go-sdk/oss"
|
"github.com/aliyun/aliyun-oss-go-sdk/oss"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ossx struct {
|
type Ossx struct {
|
||||||
endPoint string
|
endPoint string
|
||||||
accessKeyId string
|
accessKeyId string
|
||||||
accessKeySecret string
|
accessKeySecret string
|
||||||
@@ -17,7 +17,7 @@ type ossx struct {
|
|||||||
bucket *oss.Bucket
|
bucket *oss.Bucket
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewOssx(endPoint string, accessKeyId string, accessKeySecret string, bucketName string) (*ossx, error) {
|
func NewOssx(endPoint string, accessKeyId string, accessKeySecret string, bucketName string) (*Ossx, error) {
|
||||||
client, err := oss.New(endPoint, accessKeyId, accessKeySecret)
|
client, err := oss.New(endPoint, accessKeyId, accessKeySecret)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -28,7 +28,7 @@ func NewOssx(endPoint string, accessKeyId string, accessKeySecret string, bucket
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &ossx{
|
return &Ossx{
|
||||||
endPoint: endPoint,
|
endPoint: endPoint,
|
||||||
accessKeyId: accessKeyId,
|
accessKeyId: accessKeyId,
|
||||||
accessKeySecret: accessKeySecret,
|
accessKeySecret: accessKeySecret,
|
||||||
@@ -39,7 +39,7 @@ func NewOssx(endPoint string, accessKeyId string, accessKeySecret string, bucket
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 上传文件
|
// 上传文件
|
||||||
func (l *ossx) UploadByPath(objectKey string, filePath string) error {
|
func (l *Ossx) UploadByPath(objectKey string, filePath string) error {
|
||||||
// 替换
|
// 替换
|
||||||
objectKey = strings.ReplaceAll(objectKey, `\`, `/`)
|
objectKey = strings.ReplaceAll(objectKey, `\`, `/`)
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ func (l *ossx) UploadByPath(objectKey string, filePath string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 下载文件
|
// 下载文件
|
||||||
func (l *ossx) GetObjectToByte(objectKey string) ([]byte, error) {
|
func (l *Ossx) GetObjectToByte(objectKey string) ([]byte, error) {
|
||||||
// 替换
|
// 替换
|
||||||
objectKey = strings.ReplaceAll(objectKey, `\`, `/`)
|
objectKey = strings.ReplaceAll(objectKey, `\`, `/`)
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ func (l *ossx) GetObjectToByte(objectKey string) ([]byte, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 分片上传
|
// 分片上传
|
||||||
func (l *ossx) UploadByPathMultipart(objectKey string, filePath string) error {
|
func (l *Ossx) UploadByPathMultipart(objectKey string, filePath string) error {
|
||||||
// 替换
|
// 替换
|
||||||
objectKey = strings.ReplaceAll(objectKey, `\`, `/`)
|
objectKey = strings.ReplaceAll(objectKey, `\`, `/`)
|
||||||
|
|
||||||
@@ -82,14 +82,14 @@ func (l *ossx) UploadByPathMultipart(objectKey string, filePath string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 上传文件
|
// 上传文件
|
||||||
func (l *ossx) UploadByByte(objectKey string, body []byte) error {
|
func (l *Ossx) UploadByByte(objectKey string, body []byte) error {
|
||||||
objectKey = strings.ReplaceAll(objectKey, `\`, `/`)
|
objectKey = strings.ReplaceAll(objectKey, `\`, `/`)
|
||||||
|
|
||||||
return l.bucket.PutObject(objectKey, strings.NewReader(string(body)))
|
return l.bucket.PutObject(objectKey, strings.NewReader(string(body)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取远端MD5
|
// 获取远端MD5
|
||||||
func (l *ossx) GetObjectMd5(objectKey string) (string, error) {
|
func (l *Ossx) GetObjectMd5(objectKey string) (string, error) {
|
||||||
props, err := l.bucket.GetObjectDetailedMeta(objectKey)
|
props, err := l.bucket.GetObjectDetailedMeta(objectKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
|||||||
+7
-4
@@ -7,21 +7,24 @@ import (
|
|||||||
"github.com/aliyun/alibaba-cloud-sdk-go/services/dysmsapi"
|
"github.com/aliyun/alibaba-cloud-sdk-go/services/dysmsapi"
|
||||||
)
|
)
|
||||||
|
|
||||||
type sms struct {
|
type Sms struct {
|
||||||
endPoint string
|
endPoint string
|
||||||
accessKeyId string
|
accessKeyId string
|
||||||
accessKeySecret string
|
accessKeySecret string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSms(endPoint string, accessKeyId string, accessKeySecret string) *sms {
|
func NewSms(endPoint string, accessKeyId string, accessKeySecret string) *Sms {
|
||||||
return &sms{
|
if endPoint == "" {
|
||||||
|
endPoint = "dysmsapi.aliyuncs.com"
|
||||||
|
}
|
||||||
|
return &Sms{
|
||||||
endPoint: endPoint,
|
endPoint: endPoint,
|
||||||
accessKeyId: accessKeyId,
|
accessKeyId: accessKeyId,
|
||||||
accessKeySecret: accessKeySecret,
|
accessKeySecret: accessKeySecret,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *sms) Send(phone, signName, templateCode string, params map[string]interface{}) error {
|
func (s *Sms) Send(phone, signName, templateCode string, params map[string]interface{}) error {
|
||||||
client, err := dysmsapi.NewClientWithAccessKey(s.endPoint, s.accessKeyId, s.accessKeySecret)
|
client, err := dysmsapi.NewClientWithAccessKey(s.endPoint, s.accessKeyId, s.accessKeySecret)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in New Issue
Block a user