Yandex
Yandex Disk 是由 Yandex 创建的云存储解决方案。
配置
下面是制作 Yandex 配置的示例。 首先运行
rclone config
这将引导你完成交互式设置过程:
No remotes found, make a new one?
n) New remote
s) Set configuration password
n/s> n
name> remote
Type of storage to configure.
Choose a number from below, or type in your own value
[snip]
XX / Yandex Disk
\ "yandex"
[snip]
Storage> yandex
Yandex Client Id - leave blank normally.
client_id>
Yandex Client Secret - leave blank normally.
client_secret>
Remote config
Use web browser to automatically authenticate rclone with remote?
* Say Y if the machine running rclone has a web browser you can use
* Say N if running rclone on a (remote) machine without web browser access
If not sure try Y. If Y failed, try N.
y) Yes
n) No
y/n> y
If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth
Log in and authorize rclone for access
Waiting for code...
Got code
Configuration complete.
Options:
- type: yandex
- client_id:
- client_secret:
- token: {"access_token":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","token_type":"OAuth","expiry":"2016-12-29T12:27:11.362788025Z"}
Keep this "remote" remote?
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y
请参考 远程设置文档 ,了解如何在没有互联网浏览器的机器上进行设置。
请注意,rclone 会在你的本地机器上运行一个 Web 服务器,用于收集 Yandex Disk 返回的令牌。该服务器仅在打开浏览器到你获取到验证码的这段时间内运行。它的地址是 http://127.0.0.1:53682/
,如果你正在运行主机防火墙,可能需要临时解除对该地址的封锁。
配置完成后,你可以像这样使用 rclone
:
查看顶级目录
rclone lsd remote:
创建一个新目录
rclone mkdir remote:directory
列出目录的内容
rclone ls remote:directory
将 /home/local/directory
同步到远程路径,并删除该路径中多余的文件。
rclone sync --interactive /home/local/directory remote:directory
Yandex 的路径可以根据需要设置深度,例如 remote:directory/subdirectory
。
修改时间和哈希值
支持修改时间,并以自定义元数据 rclone_modified
的形式,以带纳秒的 RFC3339 格式精确到 1 纳秒进行存储。
Yandex Disk 原生支持 MD5 哈希算法。
清空回收站
如果你想清空回收站,可以使用 rclone cleanup remote:
命令,该命令将永久删除所有已删除的文件。此命令不接受任何路径参数。
配额信息
要查看当前的配额,可以使用 rclone about remote:
命令,该命令将显示你的使用限制(配额)和当前使用情况。
受限文件名的字符
默认的受限字符集 会被替换。
无效的 UTF-8 字节也会被 替换,因为它们不能用于 JSON 字符串。
标准选项
以下是 Yandex(Yandex Disk)特有的标准选项。
–yandex-client-id
OAuth 客户端 ID。
通常留空。
属性:
- 配置项:client_id
- 环境变量:RCLONE_YANDEX_CLIENT_ID
- 类型:字符串
- 是否必需:否
–yandex-client-secret
OAuth 客户端密钥。
通常留空。
属性:
- 配置项:client_secret
- 环境变量:RCLONE_YANDEX_CLIENT_SECRET
- 类型:字符串
- 是否必需:否
高级选项
以下是 Yandex(Yandex Disk)特有的高级选项。
–yandex-token
OAuth 访问令牌,以 JSON 格式表示。
属性:
- 配置项:token
- 环境变量:RCLONE_YANDEX_TOKEN
- 类型:字符串
- 是否必需:否
–yandex-auth-url
认证服务器 URL。
留空则使用提供商的默认值。
属性:
- 配置项:auth_url
- 环境变量:RCLONE_YANDEX_AUTH_URL
- 类型:字符串
- 是否必需:否
–yandex-token-url
令牌服务器 URL。
留空则使用提供商的默认值。
属性:
- 配置项:token_url
- 环境变量:RCLONE_YANDEX_TOKEN_URL
- 类型:字符串
- 是否必需:否
–yandex-client-credentials
使用客户端凭证 OAuth 流程。
这将使用 RFC 6749 中描述的 OAuth2 客户端凭证流程。
属性:
- 配置项:client_credentials
- 环境变量:RCLONE_YANDEX_CLIENT_CREDENTIALS
- 类型:布尔值
- 默认值:false
–yandex-hard-delete
永久删除文件,而不是将其放入回收站。
属性:
- 配置项:hard_delete
- 环境变量:RCLONE_YANDEX_HARD_DELETE
- 类型:布尔值
- 默认值:false
–yandex-encoding
后端的编码方式。
有关更多信息,请参阅 概述中的编码部分。
属性:
- 配置项:encoding
- 环境变量:RCLONE_YANDEX_ENCODING
- 类型:Encoding
- 默认值:Slash,Del,Ctl,InvalidUtf8,Dot
–yandex-spoof-ua
将用户代理设置为匹配 Yandex Disk 客户端的官方版本。可能有助于提高上传性能。
属性:
- 配置项:spoof_ua
- 环境变量:RCLONE_YANDEX_SPOOF_UA
- 类型:布尔值
- 默认值:true
–yandex-description
远程存储的描述。
属性:
- 配置项:description
- 环境变量:RCLONE_YANDEX_DESCRIPTION
- 类型:字符串
- 是否必需:否
限制
上传非常大的文件(大于约 5 GiB)时,你需要增加 --timeout
参数。这是因为 Yandex 在返回文件上传确认信息之前会暂停(可能是为了计算整个文件的 MD5 哈希值)。rclone 对超时的默认处理方式是,假设 5 分钟的暂停是一个错误并关闭连接——如果发生这种情况,你会在日志中看到 net/http: timeout awaiting response headers
错误。将超时时间设置为文件最大大小(以 GiB 为单位)的两倍应该就足够了,所以如果你想上传一个 30 GiB 的文件,将超时时间设置为 2 * 30 = 60m
,即 --timeout 60m
。
使用 Yandex.Disk 订阅服务必须拥有 Yandex 邮箱账户。即使没有邮箱账户也可以生成令牌,但 Rclone 将无法完成任何操作。
[403 - DiskUnsupportedUserAccountTypeError] User account type is not supported.