mirror of
https://github.com/pocketbase/pocketbase.git
synced 2026-10-10 00:07:27 +02:00
Allows files to be read through FileSystem interface.
The functionality is needed while Pocketbase is used in embedded mode
This commit is contained in:
1 parent
59e4939e1d
commit
a5ceee33df
2 files changed
+28
No files matched your search
@@ -285,6 +285,16 @@ var manualExtensionContentTypes = map[string]string{
|
||||
".css": "text/css", // (see https://github.com/gabriel-vasile/mimetype/pull/113)
|
||||
}
|
||||
|
||||
// / GetFile returns a file content reader for given file key
|
||||
// / NB! Make sure to call `Close()` after you are done working with it.
|
||||
func (s *System) GetFile(fileKey string) (io.ReadCloser, error) {
|
||||
br, readErr := s.bucket.NewReader(s.ctx, fileKey, nil)
|
||||
if readErr != nil {
|
||||
return nil, readErr
|
||||
}
|
||||
return br, nil
|
||||
}
|
||||
|
||||
// Serve serves the file at fileKey location to an HTTP response.
|
||||
func (s *System) Serve(res http.ResponseWriter, req *http.Request, fileKey string, name string) error {
|
||||
br, readErr := s.bucket.NewReader(s.ctx, fileKey, nil)
|
||||
|
||||
Reference in new issue
Block a user