stat
This commit is contained in:
parent
3458c6fc4e
commit
006c8de201
|
|
@ -3,13 +3,14 @@ package storage
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/minio/minio-go"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/minio/minio-go"
|
||||
|
||||
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) {
|
||||
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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue