(appId string, fileName string, contents []byte)
| 261 | } |
| 262 | |
| 263 | func WriteAppFile(appId string, fileName string, contents []byte) error { |
| 264 | if err := ValidateAppId(appId); err != nil { |
| 265 | return fmt.Errorf("invalid appId: %w", err) |
| 266 | } |
| 267 | |
| 268 | appDir, err := GetAppDir(appId) |
| 269 | if err != nil { |
| 270 | return err |
| 271 | } |
| 272 | |
| 273 | filePath, err := validateAndResolveFilePath(appDir, fileName) |
| 274 | if err != nil { |
| 275 | return err |
| 276 | } |
| 277 | |
| 278 | if err := os.MkdirAll(filepath.Dir(filePath), 0755); err != nil { |
| 279 | return fmt.Errorf("failed to create directory: %w", err) |
| 280 | } |
| 281 | |
| 282 | if err := os.WriteFile(filePath, contents, 0644); err != nil { |
| 283 | return fmt.Errorf("failed to write file: %w", err) |
| 284 | } |
| 285 | |
| 286 | return nil |
| 287 | } |
| 288 | |
| 289 | func ReadAppFile(appId string, fileName string) (*FileData, error) { |
| 290 | if err := ValidateAppId(appId); err != nil { |
no test coverage detected