/elevengo

An API client of 115 Cloud Storage Service in Go.

Primary LanguageGoMIT LicenseMIT

ElevenGo

Version Reference License

An API client of 115 Cloud Storage Service.

Example

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: "", SEID: "",
  }
  if err := agent.CredentialImport(credential); err != nil {
    log.Fatalf("Import credentail error: %s", err)
  }

  // Get file list
  it, err := agent.FileIterate("dirId")
  for ; err == nil; err = it.Next() {
    file := &elevengo.File{}
    if err = it.Get(file); err == nil {
      log.Printf("File: %d => %#v", it.Index(), file)
    }
  }
  if !elevengo.IsIteratorEnd(err) {
    log.Fatalf("Iterate files error: %s", err)
  }
}
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: "", 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)
  }
  
}

License

MIT