This commit is contained in:
wangchuxiao
2022-03-23 15:44:34 +08:00
parent 8034ddc413
commit e6c36411cb
7 changed files with 93 additions and 6 deletions
+16 -4
View File
@@ -6,8 +6,20 @@ type MinioStorageCredentialReq struct {
type MiniostorageCredentialResp struct {
SecretAccessKey string `json:"secretAccessKey"`
AccessKeyID string `json:"accessKeyID"`
SessionToken string `json:"sessionToken"`
BucketName string `json:"bucketName"`
StsEndpointURL string `json:"stsEndpointURL"`
AccessKeyID string `json:"accessKeyID"`
SessionToken string `json:"sessionToken"`
BucketName string `json:"bucketName"`
StsEndpointURL string `json:"stsEndpointURL"`
}
type MinioUploadFileReq struct {
OperationID string `json:"operationID"`
FileType int `json:"fileType"`
}
type MinioUploadFileResp struct {
URL string `json:"URL"`
NewName string `json:"newName"`
SnapshotURL string `json:"snapshotURL" binding:"omitempty"`
SnapshotNewName string `json:"snapshotName" binding:"omitempty"`
}
+4
View File
@@ -159,6 +159,10 @@ const (
//callback callbackHandleCode
CallbackHandleSuccess = 0
CallbackHandleFailed = 1
// minioUpload
OtherType = 1
VideoType = 2
)
var ContentType2PushContent = map[int64]string{
View File
+15 -1
View File
@@ -1,6 +1,11 @@
package utils
import "os"
import (
"fmt"
"math/rand"
"os"
"time"
)
// Determine whether the given path is a folder
func IsDir(path string) bool {
@@ -20,3 +25,12 @@ func IsFile(path string) bool {
func MkDir(path string) error {
return os.MkdirAll(path, os.ModePerm)
}
func GetNewFileNameAndContentType(fileType string) (string, string) {
newName := fmt.Sprintf("%d-%d%s", time.Now().UnixNano(), rand.Int(), fileType)
contentType := ""
if fileType == "img" {
contentType = "image/" + fileType[1:]
}
return newName, contentType
}