@@ -26,6 +26,7 @@ import (
26
26
"mime/multipart"
27
27
"net/http"
28
28
"os"
29
+ "path/filepath"
29
30
"strconv"
30
31
"strings"
31
32
@@ -171,7 +172,7 @@ func (c *StorageApiClient) ImportCustomTemplate(templateFile string) (*ImportCus
171
172
return nil , err
172
173
}
173
174
174
- func (c * StorageApiClient ) ExportCustomTemplate (templateId string ) (* string , error ) {
175
+ func (c * StorageApiClient ) ExportCustomTemplate (templateId , path string ) (* string , error ) {
175
176
176
177
if templateId == "" {
177
178
return nil , fmt .Errorf ("invalid template id: no id provided" )
@@ -195,7 +196,7 @@ func (c *StorageApiClient) ExportCustomTemplate(templateId string) (*string, err
195
196
logrus .Debugf ("Export API call status: %d" , res .StatusCode )
196
197
197
198
if res .StatusCode == 200 || res .StatusCode == 201 {
198
- outfile , fileExportPath , err := createNewLocalFile (templateId , res )
199
+ outfile , fileExportPath , err := createNewLocalFile (templateId , path , res )
199
200
if err != nil {
200
201
return nil , err
201
202
}
@@ -219,8 +220,8 @@ func (c *StorageApiClient) ExportCustomTemplate(templateId string) (*string, err
219
220
return nil , err
220
221
}
221
222
222
- func createNewLocalFile (templateId string , res * http.Response ) (* os.File , string , error ) {
223
- fileExportPath , err := composeNewLocalFileName (templateId , res )
223
+ func createNewLocalFile (templateId , path string , res * http.Response ) (* os.File , string , error ) {
224
+ fileExportPath , err := composeNewLocalFileName (templateId , path , res )
224
225
if err != nil {
225
226
return nil , "" , err
226
227
}
@@ -231,8 +232,11 @@ func createNewLocalFile(templateId string, res *http.Response) (*os.File, string
231
232
return outfile , fileExportPath , nil
232
233
}
233
234
234
- func composeNewLocalFileName (templateId string , res * http.Response ) (string , error ) {
235
+ func composeNewLocalFileName (templateId , path string , res * http.Response ) (string , error ) {
235
236
fileExportPath := extractFileNameFromHeader (res )
237
+ if path != "" {
238
+ fileExportPath = filepath .Join (path , fileExportPath )
239
+ }
236
240
originalFileExportName := fileExportPath
237
241
if fileExportPath == "" {
238
242
fileExportPath = templateId + TemplateFileExtension
0 commit comments