Get retrieves attachment content.
(path string)
| 50 | |
| 51 | // Get retrieves attachment content. |
| 52 | func (s *AttachmentStore) Get(path string) ([]byte, error) { |
| 53 | if s.mode == "filesystem" { |
| 54 | return os.ReadFile(filepath.Join(s.dir, path)) |
| 55 | } |
| 56 | |
| 57 | s.mu.RLock() |
| 58 | defer s.mu.RUnlock() |
| 59 | data, ok := s.files[path] |
| 60 | if !ok { |
| 61 | return nil, fmt.Errorf("attachment not found: %s", path) |
| 62 | } |
| 63 | return data, nil |
| 64 | } |
| 65 | |
| 66 | // GetReader returns a reader for the attachment. |
| 67 | func (s *AttachmentStore) GetReader(path string) (io.ReadCloser, error) { |
no outgoing calls