修改为大写
This commit is contained in:
+8
-8
@@ -8,7 +8,7 @@ import (
|
||||
"github.com/aliyun/aliyun-oss-go-sdk/oss"
|
||||
)
|
||||
|
||||
type ossx struct {
|
||||
type Ossx struct {
|
||||
endPoint string
|
||||
accessKeyId string
|
||||
accessKeySecret string
|
||||
@@ -17,7 +17,7 @@ type ossx struct {
|
||||
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)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -28,7 +28,7 @@ func NewOssx(endPoint string, accessKeyId string, accessKeySecret string, bucket
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &ossx{
|
||||
return &Ossx{
|
||||
endPoint: endPoint,
|
||||
accessKeyId: accessKeyId,
|
||||
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, `\`, `/`)
|
||||
|
||||
@@ -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, `\`, `/`)
|
||||
|
||||
@@ -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, `\`, `/`)
|
||||
|
||||
@@ -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, `\`, `/`)
|
||||
|
||||
return l.bucket.PutObject(objectKey, strings.NewReader(string(body)))
|
||||
}
|
||||
|
||||
// 获取远端MD5
|
||||
func (l *ossx) GetObjectMd5(objectKey string) (string, error) {
|
||||
func (l *Ossx) GetObjectMd5(objectKey string) (string, error) {
|
||||
props, err := l.bucket.GetObjectDetailedMeta(objectKey)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
||||
+7
-4
@@ -7,21 +7,24 @@ import (
|
||||
"github.com/aliyun/alibaba-cloud-sdk-go/services/dysmsapi"
|
||||
)
|
||||
|
||||
type sms struct {
|
||||
type Sms struct {
|
||||
endPoint string
|
||||
accessKeyId string
|
||||
accessKeySecret string
|
||||
}
|
||||
|
||||
func NewSms(endPoint string, accessKeyId string, accessKeySecret string) *sms {
|
||||
return &sms{
|
||||
func NewSms(endPoint string, accessKeyId string, accessKeySecret string) *Sms {
|
||||
if endPoint == "" {
|
||||
endPoint = "dysmsapi.aliyuncs.com"
|
||||
}
|
||||
return &Sms{
|
||||
endPoint: endPoint,
|
||||
accessKeyId: accessKeyId,
|
||||
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)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user