Convert docx to markdown in golang(Picture Problem)

hi, I want to convert word to markdown in golang.
Attached is my code demonstration.
But in the end I only got an MD file.
I want to get the pictures in the MD file at the same time. Is there any way?

*I can get the zip package( convert docx to md) in *
Convert Files Online - Word, PDF, HTML, JPG And Many More
aspose-word-convert.zip (193.6 KB)
aspose-word-convert.zip (194 KB)

@Lifa

You may use the SaveAsOnline API method to save the output as a zip file using ZipOutput property of saveOptionsData object. Please also check the unit test of Aspose.Words Cloud SDK for Go; it will help you accomplish the task.

Thanks for your reply.
I used SaveAsOnline according to your instructions, but an error occurred:

buildReport Failed:{“RequestId”:“Root=1-639293a5-231a0ce638a64c7c064db668”,“Error”:{“Code”:“ErrorInvalidInputData”,“DateTime”:“0001-01-01T00:00:00Z”,“Description”:“Operation Failed. The input data is not valid.”,“Message”:“Can not deserialize string ‘\u0026{\u003cnil\u003e \u003cnil\u003e \u003cnil\u003e \u003cnil\u003e \u003cnil\u003e 0xc00004ac40 \u003cnil\u003e \u003cnil\u003e 0xc00004ac30 \u003cnil\u003e \u003cnil\u003e \u003cnil\u003e \u003cnil\u003e \u003cnil\u003e 0xc00000a9f0}’.”}}

Code Demo:

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/v2110/api"

"github.com/aspose-words-cloud/aspose-words-cloud-go/v2110/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,

}

_, 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, responseWord.Body)

}

aspose-word-convert2.zip (191.0 KB)

@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[""])
}

Yes, I used aspose-words-cloud-go/v2110.
But the demo code keeps reporting errors, prompt: The input data is not valid

buildReport Failed:{“RequestId”:“Root=1-639fdd42-1a38c73c7a13e1da3d6cf203”,“Error”:{“Code”:“ErrorInvalidInputData”,“DateTime”:“0001-01-01T00:00:00Z”,“Description”:“Operation Failed. The input data is not valid.”,“Message”:“Can not deserialize string ‘\u0026{\u003cnil\u003e \u003cnil\u003e \u003cnil\u003e \u003cnil\u003e \u003cnil\u003e
0xc00004ac40 \u003cnil\u003e \u003cnil\u003e 0xc00004ac30 \u003cnil\u003e \u003cnil\u003e \u003cnil\u003e \u003cnil\u003e \u003cnil\u003e 0xc00000a9f0}’.”}}

@Lifa

Please try Aspose.Words Cloud SDK for Go 22.10 instead of 21.10.

	"github.com/aspose-words-cloud/aspose-words-cloud-go/v2210/api"
	"github.com/aspose-words-cloud/aspose-words-cloud-go/v2210/api/models"