How to download file with golang

how to download file with golang api?

first to use to login the filesystem.

but the message return: {“message”:“CSRF check failed”}

how to set the cookie or the authority?

IMHO, easiest way is finding a webdav client library for golang.

use the client, but it doesnt work.
it return a html login page of the owncloud.

func test_download_file(webdavFilePath string, localpath string) {
	root := "myroot"
	user := "myuser"
	passwd := "***"
	client := gowebdav.NewClient(root, user, passwd)

	reader, err := client.ReadStream(webdavFilePath)
	if err != nil {
		fmt.Println("read stream err")

	file, _ := os.Create(localpath)
	defer file.Close()

	io.Copy(file, reader)

find a library in github. and it is a perfect fit.

try to add your domain from personal panel, security section.


Yes. Perfect use case for CORS. Hope this helps!