|
|
|
@ -10,6 +10,7 @@ import (
|
|
|
|
|
"github.com/Masterminds/semver/v3"
|
|
|
|
|
"github.com/minio/minio-go/v7"
|
|
|
|
|
"github.com/rocboss/paopao-ce/internal/core"
|
|
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
@ -88,10 +89,11 @@ func (s *minioCreateRetentionServant) PersistObject(objectKey string) error {
|
|
|
|
|
|
|
|
|
|
func (s *minioCreateTempDirServant) PutObject(objectKey string, reader io.Reader, objectSize int64, contentType string, persistance bool) (string, error) {
|
|
|
|
|
opts := minio.PutObjectOptions{ContentType: contentType}
|
|
|
|
|
objectName := objectKey
|
|
|
|
|
if !persistance {
|
|
|
|
|
objectKey = s.tempDir + objectKey
|
|
|
|
|
objectName = s.tempDir + objectKey
|
|
|
|
|
}
|
|
|
|
|
_, err := s.client.PutObject(context.Background(), s.bucket, objectKey, reader, objectSize, opts)
|
|
|
|
|
_, err := s.client.PutObject(context.Background(), s.bucket, objectName, reader, objectSize, opts)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
@ -101,7 +103,7 @@ func (s *minioCreateTempDirServant) PutObject(objectKey string, reader io.Reader
|
|
|
|
|
func (s *minioCreateTempDirServant) PersistObject(objectKey string) error {
|
|
|
|
|
_, err := s.client.StatObject(context.Background(), s.bucket, objectKey, minio.StatObjectOptions{})
|
|
|
|
|
if err == nil {
|
|
|
|
|
// do nothing if object exist
|
|
|
|
|
logrus.Debugf("object exist so do nothing objectKey: %s", objectKey)
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|