This commit is contained in:
jiangyong 2026-03-13 10:44:51 +08:00
parent 3458c6fc4e
commit 006c8de201
1 changed files with 20 additions and 2 deletions

View File

@ -3,13 +3,14 @@ package storage
import ( import (
"context" "context"
"fmt" "fmt"
"github.com/minio/minio-go"
"net/http" "net/http"
"net/url" "net/url"
"path" "path"
"strings" "strings"
"time" "time"
"github.com/minio/minio-go"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )
@ -129,7 +130,24 @@ func (s *Minio) Url(objectName string, expire time.Duration) string {
} }
func (s *Minio) Stat(objectName string) (*ObjectInfo, error) { func (s *Minio) Stat(objectName string) (*ObjectInfo, error) {
return nil, nil if err := s.Init(); err != nil {
return nil, err
}
objectName = strings.TrimLeft(objectName, "/ ")
stat, err := s.client.StatObject(s.config.Bucket, objectName, minio.StatObjectOptions{})
if err != nil {
log.Errorf("stat object from minio error:%s", err.Error())
return nil, err
}
info := &ObjectInfo{
Size: stat.Size,
Hash: stat.ETag,
MimeType: stat.ContentType,
PutTime: stat.LastModified.Unix(),
}
return info, nil
} }
func (s *Minio) Fetch(urlStr, objectName string) error { func (s *Minio) Fetch(urlStr, objectName string) error {