用Go编写的Yandex disk REST API客户端
安装
go get -u github.com/EmirShimshir/yandexDiskApiClient
描述
这个Yandex disk REST API客户端(SDK)将帮助你简化你的应用程序与Yandex Disk的整合:https://yandex.ru/dev/disk/rest/
NewClient(oAuth string, timeout time.Duration) (*Client, error) - 新客户端的构造函数
(c *Client) GetDiskInfo(ctx context.Context) (*Disk, error) - 为您提供磁盘的信息
(c *Client) GetFiles(ctx context.Context, limit int) (*FilesResourceList, error) - 给你提供你的文件的信息
(c *Client) Delete(ctx context.Context, path string, permanently bool) (*SuccessResponse, error) - 从磁盘中删除文件
(c *Client) Download(ctx context.Context, path string) (*SuccessResponse, error) - 给你提供你在磁盘中的文件的下载地址
(c *Client) Upload(ctx context.Context, path string) (*SuccessResponse, error) - 给你提供你的文件的上传网址,磁盘中的路径
(c *Client) UploadByURL(ctx context.Context, path string, url string) - 将你的文件通过网址上传到你的磁盘
(c *Client) GetPublicFiles(ctx context.Context, limit int) (*FilesResourceList, error) - 给你提供关于你的公共文件的信息
(c *Client) Publish(ctx context.Context, path string) (*SuccessResponse, error) - 在你的磁盘上发布文件
(c *Client) Unpublish(ctx context.Context, path string) (*SuccessResponse, error) - 在你的磁盘上取消发布文件
(c *Client) Move(ctx context.Context, from string, path string) (*SuccessResponse, error) - 在磁盘中移动你的文件或文件夹
(c *Client) Copy(ctx context.Context, from string, path string) (*SuccessResponse, error) - 复制磁盘中的文件或文件夹
(c *Client) Mkdir(ctx context.Context, path string) (*SuccessResponse, error) - 在你的磁盘上建立文件夹
(c *Client) GetTrash(ctx context.Context, path string, limit int) (*TrashResourceList, error) - 给你提供关于你的垃圾桶的信息
(c *Client) ClearTrash(ctx context.Context, path string) (*SuccessResponse, error) - 清理你的垃圾箱文件,只有完整的垃圾箱文件路径,**"trash:/"**才有效
(c *Client) RestoreTrash(ctx context.Context, path string) (*SuccessResponse, error) - 恢复你的垃圾箱文件,//只有完整的垃圾箱路径,**"trash:/"**不起作用。
例子
package main
import (
"context"
"fmt"
"log"
"time"
"github.com/EmirShimshir/yandexDiskApiClient"
)
const oAuth = "YOUR OAUTH HERE"
func main() {
client, err := yandexDiskApiClient.NewClient(oAuth, 10*time.Second)
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
disk, err := client.GetDiskInfo(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Println(disk.Info())
}
[Sat Aug 6 13:03:50 2022] GET https://cloud-api.yandex.net/v1/disk
UserName: Emir2701
UsedSpace: 1760710963
UsedSpace: 10737418240