# RetrieveObject

This is the interface for retrieving objects from the gateway.

```golang
// RetrieveFile downloads files from the gateway
//   - url: gateway url
//   - fid: fid
//   - mnemonic: polkadot account mnemonic
//   - savepath: file save path
//
// Return:
//   - string: fid
//   - error: error message
func RetrieveFile(url, fid, mnemonic, savepath string) error
```

Example code:

```golang
package main

import (
	"bytes"
	"context"
	"fmt"
	"io"
	"log"
	"time"

	sdkgo "github.com/CESSProject/cess-go-sdk"
	"github.com/CESSProject/cess-go-sdk/core/process"
	"github.com/CESSProject/cess-go-sdk/utils"
)

// Substrate well-known mnemonic:
//
//	https://github.com/substrate-developer-hub/substrate-developer-hub.github.io/issues/613
//  - cXgaee2N8E77JJv9gdsGAckv1Qsf3hqWYf7NL4q6ZuQzuAUtB
var MY_MNEMONIC = "bottom drive obey lake curtain smoke basket hold race lonely fit walk"

const PublicGateway = "http://deoss-pub-gateway.cess.network/"
const PublicGatewayAccount = "cXhwBytXqrZLr1qM5NHJhCzEMckSTzNKw17ci2aHft6ETSQm9"
const RetrieveFid = "Your Fid"

func main() {
	// download file from gateway
	fid, err := process.RetrieveObject(PublicGateway, RetrieveFid, MY_MNEMONIC)
	if err != nil {
		panic(err)
	}
    defer body.Close()
	data, err := io.ReadAll(body)
	if err != nil {
		panic(err)
	}
	fmt.Println(string(data))
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.cess.network/developer/cess-sdk/sdk-golang/object_file/retrieveobject.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
