MCPcopy
hub / github.com/pocketbase/pocketbase / FindUploadedFiles

Method FindUploadedFiles

tools/router/event.go:101–125  ·  view source on GitHub ↗

FindUploadedFiles extracts all form files of "key" from a http request and returns a slice with filesystem.File instances (if any).

(key string)

Source from the content-addressed store, hash-verified

99// FindUploadedFiles extracts all form files of "key" from a http request
100// and returns a slice with filesystem.File instances (if any).
101func (e *Event) FindUploadedFiles(key string) ([]*filesystem.File, error) {
102 if e.Request.MultipartForm == nil {
103 err := e.Request.ParseMultipartForm(DefaultMaxMemory)
104 if err != nil {
105 return nil, err
106 }
107 }
108
109 if e.Request.MultipartForm == nil || e.Request.MultipartForm.File == nil || len(e.Request.MultipartForm.File[key]) == 0 {
110 return nil, http.ErrMissingFile
111 }
112
113 result := make([]*filesystem.File, 0, len(e.Request.MultipartForm.File[key]))
114
115 for _, fh := range e.Request.MultipartForm.File[key] {
116 file, err := filesystem.NewFileFromMultipart(fh)
117 if err != nil {
118 return nil, err
119 }
120
121 result = append(result, file)
122 }
123
124 return result, nil
125}
126
127// Store
128// -------------------------------------------------------------------

Callers 4

TestFindUploadedFilesFunction · 0.95
extractUploadedFilesFunction · 0.80
backupUploadFunction · 0.80

Calls 1

NewFileFromMultipartFunction · 0.92

Tested by 2

TestFindUploadedFilesFunction · 0.76