An API client of 115 Cloud Storage Service.
High-level API
package main
import (
"github.com/deadblue/elevengo"
"log"
)
func main() {
// Initialize agent
agent := elevengo.Default()
// Import credential
credential := &elevengo.Credential{
UID: "", CID: "", KID: "", SEID: "",
}
if err := agent.CredentialImport(credential); err != nil {
log.Fatalf("Import credentail error: %s", err)
}
// Iterate files under specific directory
if it, err := agent.FileIterate("dirId"); err != nil {
log.Fatalf("Iterate files error: %s", err)
} else {
log.Printf("Total files: %d", it.Count())
for index, file := range it.Items() {
log.Printf("%d => %#v", index, file)
}
}
}
Low-level API
package main
import (
"context"
"log"
"github.com/deadblue/elevengo"
"github.com/deadblue/elevengo/lowlevel/api"
)
func main() {
// Initialize agent
agent := elevengo.Default()
// Import credential
credential := &elevengo.Credential{
UID: "", CID: "", KID: "", SEID: "",
}
if err := agent.CredentialImport(credential); err != nil {
log.Fatalf("Import credentail error: %s", err)
}
// Get low-level API client
llc := agent.LowlevelClient()
// Init FileList API spec
spec := (&api.FiieListSpec{}).Init("dirId", 0, 32)
// Call API
if err = llc.CallApi(spec, context.Background()); err != nil {
log.Fatalf("Call API error: %s", err)
}
// Parse API result
for index, file := range spec.Result.Files {
log.Printf("File: %d => %v", index, file)
}
}
MIT