go-yadisk

module
v0.0.0-...-fbdd3d3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2017 License: MIT

README

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/*

Directories

Path Synopsis
tests

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL