(originalFilename string)
| 139 | } |
| 140 | |
| 141 | func createTempFile(originalFilename string) (*os.File, error) { |
| 142 | tempDir := filepath.Join(os.TempDir(), "ledgerforge_uploads") |
| 143 | if err := os.MkdirAll(tempDir, 0o755); err != nil { |
| 144 | return nil, fmt.Errorf("error creating temporary directory: %w", err) |
| 145 | } |
| 146 | |
| 147 | prefix := fmt.Sprintf("%s_", filepath.Base(originalFilename)) |
| 148 | tempFile, err := os.CreateTemp(tempDir, prefix) |
| 149 | if err != nil { |
| 150 | return nil, fmt.Errorf("error creating temporary file: %w", err) |
| 151 | } |
| 152 | |
| 153 | return tempFile, nil |
| 154 | } |
| 155 | |
| 156 | func cleanupTempFile(file *os.File) { |
| 157 | if file != nil { |
no outgoing calls
no test coverage detected