sirius/internal/controller/file/file.go

34 lines
541 B
Go
Raw Permalink Normal View History

2023-04-28 02:35:30 +03:00
package file
import (
"os"
"path"
"strings"
2023-04-28 02:35:30 +03:00
"gitstore.ru/tolikproh/sirius/internal/service"
)
func FileConvert(srcFilePathName string) error {
srcDir, srcFileName := path.Split(srcFilePathName)
dstFileName := strings.Split(srcFileName, ".")[0] + ".xlsx"
buffer, err := os.ReadFile(srcDir + srcFileName)
if err != nil {
return err
}
2023-04-28 02:35:30 +03:00
respBuff, err := service.SiriusConv(buffer)
if err != nil {
return err
}
err = os.WriteFile(srcDir+dstFileName, respBuff.Bytes(), 0644)
if err != nil {
return err
}
return nil
}