@Lifa
Please note that the output of the SaveAsOnline API is multipart, so you need to use the parsed response to save the output to your local drive. Please see the following example working code for reference.
Secondly, you are using a quite old SDK version. Please use the latest version of the Aspose.Words Cloud SDK for Go. However, unfortunately, 22.11 and 22.12 are not working as expected at the moment. We have logged a ticket(WORDSCLOUD-2181) to fix them. Meanwhile, please use the Aspose.Words Cloud SDK for Go 22.10.
package main
import (
// "github.com/aspose-words-cloud/aspose-words-cloud-go/v2007/api"
// "github.com/aspose-words-cloud/aspose-words-cloud-go/v2007/api/models"
"fmt"
"io"
"os"
"github.com/aspose-words-cloud/aspose-words-cloud-go/v2210/api"
"github.com/aspose-words-cloud/aspose-words-cloud-go/v2210/api/models"
)
func main() {
hope_format := "md"
hope_file := "hope.md"
zipOutputFlag := true
config, _ := models.NewConfiguration("config.json")
wordsApi, ctx, _ := api.CreateWordsApi(config)
requestDocument, _ := os.Open("source.docx")
requestSaveOptionsData := models.SaveOptionsData{
SaveFormat: &hope_format,
FileName: &hope_file,
ZipOutput: &zipOutputFlag,
}
saveRequestOptions := map[string]interface{}{}
saveRequest := &models.SaveAsOnlineRequest{
Document: requestDocument,
SaveOptionsData: &requestSaveOptionsData,
Optionals: saveRequestOptions,
}
result, responseWord, err_BuildReport := wordsApi.SaveAsOnline(ctx, saveRequest)
defer responseWord.Body.Close()
if err_BuildReport != nil {
fmt.Println("buildReport Failed:" + err_BuildReport.Error())
return
}
saveFileName := "result.zip"
output, errSave := os.Create(saveFileName)
defer output.Close()
if errSave != nil {
fmt.Println("Save Failed:" + errSave.Error())
return
}
io.Copy(output, result.Document[""])
}