diff --git a/internal/object/object.service.go b/internal/object/object.service.go index 4cd6146..d80f0b3 100644 --- a/internal/object/object.service.go +++ b/internal/object/object.service.go @@ -3,6 +3,8 @@ package object import ( "context" "fmt" + "path/filepath" + "strings" proto "github.com/isd-sgcu/rpkm67-go-proto/rpkm67/store/object/v1" "github.com/isd-sgcu/rpkm67-store/config" @@ -41,7 +43,9 @@ func (s *serviceImpl) Upload(_ context.Context, req *proto.UploadObjectRequest) return nil, status.Error(codes.Internal, constant.InternalServerErrorMessage) } - objectKey := req.Filename + "_" + randomString + ext := filepath.Ext(req.Filename) + filename := strings.TrimSuffix(req.Filename, ext) + objectKey := filename + "_" + randomString + ext url, key, err := s.repo.Upload(req.Data, s.conf.BucketName, objectKey) if err != nil {