package created
This commit is contained in:
parent
79d9ae5ab5
commit
d5610fbb30
4 changed files with 122 additions and 0 deletions
32
internal/httpDelivery/service.go
Normal file
32
internal/httpDelivery/service.go
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue