Update ExportCDRs in apier

This commit is contained in:
TeoV
2017-11-07 13:28:02 +02:00
committed by Dan Christian Bogos
parent aa9ba31e6c
commit fa185d42ca

View File

@@ -25,17 +25,17 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
"io/ioutil"
"net/url"
"os"
"path"
"strconv"
"strings"
"time"
"unicode/utf8"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
)
func (self *ApierV1) ExportCdrsToZipString(attr utils.AttrExpFileCdrs, reply *string) error {
@@ -270,9 +270,16 @@ func (self *ApierV1) ExportCDRs(arg ArgExportCDRs, reply *RplExportedCDRs) (err
if arg.ExportFileName != nil && len(*arg.ExportFileName) != 0 {
fileName = *arg.ExportFileName
}
filePath := path.Join(eDir, fileName)
if exportFormat == utils.DRYRUN {
var filePath string
switch exportFormat {
case utils.MetaFileFWV, utils.MetaFileCSV:
filePath = path.Join(eDir, fileName)
case utils.DRYRUN:
filePath = utils.DRYRUN
default:
u, _ := url.Parse(eDir)
u.Path = path.Join(u.Path, fileName)
filePath = u.String()
}
usageMultiplyFactor := exportTemplate.UsageMultiplyFactor
for k, v := range arg.UsageMultiplyFactor {
@@ -296,7 +303,8 @@ func (self *ApierV1) ExportCDRs(arg ArgExportCDRs, reply *RplExportedCDRs) (err
} else if len(cdrs) == 0 {
return
}
cdrexp, err := engine.NewCDRExporter(cdrs, exportTemplate, exportFormat, filePath, utils.META_NONE, exportID,
cdrexp, err := engine.NewCDRExporter(cdrs, exportTemplate, exportFormat,
filePath, utils.META_NONE, exportID,
synchronous, attempts, fieldSep, usageMultiplyFactor,
costMultiplyFactor, roundingDecimals, self.Config.HttpSkipTlsVerify, self.HTTPPoster)
if err != nil {