MCPcopy Create free account
hub / github.com/53AI/53AIHub / resolveWPSVisibleFileName

Function resolveWPSVisibleFileName

api/controller/wps.go:177–201  ·  view source on GitHub ↗

resolveWPSVisibleFileName returns the file name that should be exposed to WPS. It strips internal workspace prefixes such as "output/" so the editor only sees the user-facing name.

(file *model.File)

Source from the content-addressed store, hash-verified

175// It strips internal workspace prefixes such as "output/" so the editor only
176// sees the user-facing name.
177func resolveWPSVisibleFileName(file *model.File) string {
178 if file == nil {
179 return "file"
180 }
181
182 candidates := []string{}
183 if file.UploadFile != nil {
184 candidates = append(candidates, file.UploadFile.FileName)
185 }
186 candidates = append(candidates, file.Path)
187
188 for _, candidate := range candidates {
189 name := strings.TrimSpace(candidate)
190 if name == "" {
191 continue
192 }
193 name = strings.TrimPrefix(name, "/")
194 name = path.Base(name)
195 if name != "" && name != "." && name != "/" {
196 return name
197 }
198 }
199
200 return "file"
201}
202
203func getWPSFile(c *gin.Context) (any, error) {
204 file, wpsErr := getWPSFileCommon(c, true)

Callers 2

getWPSFileFunction · 0.85
executeWPSFileUploadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected