Skip to content

chibisov/go-yadisk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Golang client for the Yandex.Disk API.

Work in progress

Usage

import "github.com/chibisov/go-yadisk/yadisk"

Construct a new Yandex.Disk client, then use the various services on the client to access different parts of the Yandex.Disk API. For example:

client := yadisk.NewClient("ACCESS_TOKEN")
ctx := context.Background()

// get a general information about a user's Disk
disk, response, err = client.Disk.Get(ctx)

// get meta information about file or directory
resources, response, err = client.Resources.Get(ctx, "/")

// get meta information about resources in the trash
resources, response, err = client.Trash.Resources.Get(ctx, "/")

// restore file from the trash
resource, response, err = client.Trash.Resources.Restore(ctx, "/file.jpg")

// get data for download a file
downloadInfo, response, err = client.Resources.Download(ctx, "/file.jpg")

// get data for uploading a file
downloadInfo, response, err = client.Resources.Upload(ctx, "/file.jpg")

Tests

Running only unit tests:

$ go test ./tests/unit/

Running only integration tests:

$ go test ./tests/integration/

For integration tests you need to provide some environment variables for credentials:

$ ACCESS_TOKEN=123 go test ./tests/integration/

You can save it to .test.config (which is ignored by git) and run like this:

$ eval $(cat .test.config) go test ./tests/integration/

Running all tests:

$ go test ./tests/*

Releases

No releases published

Packages

No packages published

Languages