image-storage/internal/httpDelivery/service.go
2025-10-25 17:39:57 +03:00

32 lines
601 B
Go

package httpDelivery
import (
"imageStorage/internal/interfaces"
"os"
"path/filepath"
)
type service struct {
utils interfaces.Utils
}
func newService(utils interfaces.Utils) *service {
return &service{
utils: utils,
}
}
func (s *service) GetImage(userUuid, merchUuid, imgType string) (string, error) {
path := s.utils.MerchImageVolumePath(userUuid, merchUuid)
file := s.utils.FilenameFromType(imgType)
fullPath := filepath.Join(path, file)
if _, err := os.Stat(fullPath); err != nil {
if os.IsNotExist(err) {
return "", notFound
}
return "", err
}
return fullPath, nil
}