diff --git a/cmd/backend/docx.go b/cmd/backend/docx.go index 9affbb6..37f895c 100644 --- a/cmd/backend/docx.go +++ b/cmd/backend/docx.go @@ -14,15 +14,13 @@ import ( func ConvertToMarkdown(c *Config, filename string) ([]byte, error) { var stderr bytes.Buffer - articleID := uuid.New() - articleFileName := fmt.Sprint("/tmp/", articleID, ".md") - - tmpDir, err := os.MkdirTemp("/tmp", "cpolis_images") + tmpDir, err := os.MkdirTemp(os.TempDir(), "cpolis_images") if err != nil { return nil, fmt.Errorf("error creating temporary directory: %v", err) } defer os.RemoveAll(tmpDir) + articleFileName := filepath.Join(os.TempDir(), fmt.Sprint(uuid.New(), ".md")) cmd := exec.Command("pandoc", "-s", "-f", "docx", "-t", "commonmark_x", "-o", articleFileName, "--extract-media", tmpDir, filename) // TODO: Is writing to a file necessary? cmd.Stderr = &stderr if err = cmd.Run(); err != nil {