refactoring: now detecting file type using filename from form data. Also, only one accepted content type

This commit is contained in:
Julien Neuhart
2018-04-08 21:49:02 +02:00
parent cdeef33ff7
commit bca02f6198
14 changed files with 119 additions and 400 deletions

View File

@@ -3,7 +3,6 @@ package process
import (
"bytes"
"fmt"
"os/exec"
"text/template"
"time"
@@ -37,7 +36,7 @@ func (e *impossibleConversionError) Error() string {
func Unconv(workingDir string, file *gfile.File) (string, error) {
cmdData := &conversionData{
FilePath: file.Path,
ResultFilePath: fmt.Sprintf("%s%s", gfile.MakeFilePath(workingDir), gfile.PDFExt),
ResultFilePath: gfile.MakeFilePath(workingDir, ".pdf"),
}
var (
@@ -81,7 +80,7 @@ type mergeData struct {
func Merge(workingDir string, filesPaths []string) (string, error) {
cmdData := &mergeData{
FilesPaths: filesPaths,
ResultFilePath: fmt.Sprintf("%s%s", gfile.MakeFilePath(workingDir), gfile.PDFExt),
ResultFilePath: gfile.MakeFilePath(workingDir, ".pdf"),
}
cmdTemplate := commandsConfig.Merge.Template
@@ -127,7 +126,6 @@ func run(command string, timeout int) error {
if err := cmd.Process.Kill(); err != nil {
return err
}
return &commandTimeoutError{}
case err := <-done:
if err != nil {