|
@@ -10,61 +10,61 @@ import (
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
-func GetMinIOSTSToken() (item *Token, err error) {
|
|
|
- // MinIO服务的访问信息
|
|
|
- item = new(Token)
|
|
|
- //useSSL := false
|
|
|
- //if utils.MinIoUseSSL == "true" {
|
|
|
- // useSSL = true
|
|
|
- //}
|
|
|
- // 创建MinIO客户端
|
|
|
- //minioClient, err := minio.New(utils.MinIoEndpoint, &minio.Options{
|
|
|
- // Creds: credentials.NewStaticV4(utils.MinIoAccessKeyId, utils.MinIoAccessKeySecret, ""),
|
|
|
- // Secure: useSSL,
|
|
|
- //})
|
|
|
- //if err != nil {
|
|
|
- // return nil, err
|
|
|
- //}
|
|
|
- // 设置STS凭证请求参数
|
|
|
- //policy := `{
|
|
|
- // "Version": "2012-10-17",
|
|
|
- // "Statement": [
|
|
|
- // {
|
|
|
- // "Sid": "",
|
|
|
- // "Effect": "Allow",
|
|
|
- // "Principal": {"AWS": "arn:aws:iam::1234567890:root"},
|
|
|
- // "Action": "s3:GetObject",
|
|
|
- // "Resource": "arn:aws:s3:::<YourBucketName>/*"
|
|
|
- // }
|
|
|
- // ]
|
|
|
- //}`
|
|
|
- //expiry := time.Hour * 24 // STS凭证的过期时间
|
|
|
- //获取STS凭证
|
|
|
- //stsCredentials, err := minioClient.PresignedPutObject(context.Background(), "etastatic", "myobject", expiry)
|
|
|
- //if err != nil {
|
|
|
- // return
|
|
|
- //}
|
|
|
- item.AccessKeyId = utils.MinIoAccessKeyId
|
|
|
- item.SecretKeyId = utils.MinIoAccessKeySecret
|
|
|
- item.Endpoint = utils.MinIoEndpoint
|
|
|
- item.ImgHost = utils.MinIoImghost
|
|
|
- item.Bucketname = utils.MinIoBucketname
|
|
|
- item.UseSSL = utils.MinIoUseSSL
|
|
|
- item.RegionId = utils.MinIoRegion
|
|
|
- item.Port = utils.MinIoPort
|
|
|
- return
|
|
|
-}
|
|
|
+//func GetMinIOSTSToken() (item *Token, err error) {
|
|
|
+// // MinIO服务的访问信息
|
|
|
+// item = new(Token)
|
|
|
+// //useSSL := false
|
|
|
+// //if utils.MinIoUseSSL == "true" {
|
|
|
+// // useSSL = true
|
|
|
+// //}
|
|
|
+// // 创建MinIO客户端
|
|
|
+// //minioClient, err := minio.New(utils.MinIoEndpoint, &minio.Options{
|
|
|
+// // Creds: credentials.NewStaticV4(utils.MinIoAccessKeyId, utils.MinIoAccessKeySecret, ""),
|
|
|
+// // Secure: useSSL,
|
|
|
+// //})
|
|
|
+// //if err != nil {
|
|
|
+// // return nil, err
|
|
|
+// //}
|
|
|
+// // 设置STS凭证请求参数
|
|
|
+// //policy := `{
|
|
|
+// // "Version": "2012-10-17",
|
|
|
+// // "Statement": [
|
|
|
+// // {
|
|
|
+// // "Sid": "",
|
|
|
+// // "Effect": "Allow",
|
|
|
+// // "Principal": {"AWS": "arn:aws:iam::1234567890:root"},
|
|
|
+// // "Action": "s3:GetObject",
|
|
|
+// // "Resource": "arn:aws:s3:::<YourBucketName>/*"
|
|
|
+// // }
|
|
|
+// // ]
|
|
|
+// //}`
|
|
|
+// //expiry := time.Hour * 24 // STS凭证的过期时间
|
|
|
+// //获取STS凭证
|
|
|
+// //stsCredentials, err := minioClient.PresignedPutObject(context.Background(), "etastatic", "myobject", expiry)
|
|
|
+// //if err != nil {
|
|
|
+// // return
|
|
|
+// //}
|
|
|
+// item.AccessKeyId = utils.MinIoAccessKeyId
|
|
|
+// item.SecretKeyId = utils.MinIoAccessKeySecret
|
|
|
+// item.Endpoint = utils.MinIoEndpoint
|
|
|
+// item.ImgHost = utils.MinIoImghost
|
|
|
+// item.Bucketname = utils.MinIoBucketname
|
|
|
+// item.UseSSL = utils.MinIoUseSSL
|
|
|
+// item.RegionId = utils.MinIoRegion
|
|
|
+// item.Port = utils.MinIoPort
|
|
|
+// return
|
|
|
+//}
|
|
|
|
|
|
-type Token struct {
|
|
|
- AccessKeyId string
|
|
|
- SecretKeyId string
|
|
|
- RegionId string
|
|
|
- Bucketname string
|
|
|
- Endpoint string
|
|
|
- ImgHost string
|
|
|
- UseSSL string
|
|
|
- Port string
|
|
|
-}
|
|
|
+//type Token struct {
|
|
|
+// AccessKeyId string
|
|
|
+// SecretKeyId string
|
|
|
+// RegionId string
|
|
|
+// Bucketname string
|
|
|
+// Endpoint string
|
|
|
+// ImgHost string
|
|
|
+// UseSSL string
|
|
|
+// Port string
|
|
|
+//}
|
|
|
|
|
|
//func UploadMinIo() {
|
|
|
// ctx := context.Background()
|