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)
| 175 | // It strips internal workspace prefixes such as "output/" so the editor only |
| 176 | // sees the user-facing name. |
| 177 | func 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 | |
| 203 | func getWPSFile(c *gin.Context) (any, error) { |
| 204 | file, wpsErr := getWPSFileCommon(c, true) |
no outgoing calls
no test coverage detected