To Download the file, you need to provide the unique hash of the data(Fid), which will be returned to you when the data is uploaded successfully.
package main
import (
"context"
"fmt"
cess "github.com/CESSProject/cess-go-sdk"
)
// Substrate well-known mnemonic:
//
// https://github.com/substrate-developer-hub/substrate-developer-hub.github.io/issues/613
var MY_MNEMONIC = "bottom drive obey lake curtain smoke basket hold race lonely fit walk"
var RPC_ADDRS = []string{
"wss://testnet-rpc0.cess.cloud/ws/",
"wss://testnet-rpc1.cess.cloud/ws/",
"wss://testnet-rpc2.cess.cloud/ws/",
}
const oss_url = "http://deoss-pub-gateway.cess.cloud/"
const file_hash = "c158d7008e94d3af61033b6861aa4f35a4c2b829c7e97224fcbb54618de55945"
func main() {
sdk, err := cess.New(
context.Background(),
cess.ConnectRpcAddrs(RPC_ADDRS),
cess.Mnemonic(MY_MNEMONIC),
)
if err != nil {
panic(err)
}
// download file
fmt.Println(sdk.RetrieveFile(oss_url, file_hash, "download_file"))
}