API:Filerevert

From mediawiki.org
This page is a translated version of the page API:Filerevert and the translation is 100% complete.

POST request to revert a file to an old version.

令牌

要将文件还原到旧版本,需要CSRF令牌。 所有页面的CSRF令牌是相同的,但是每次登录时令牌都会改变。 可以通过带有type=csrf(MW 1.24+)的action=query&meta=tokens 获得CSRF令牌。 对于较旧的版本,可以使用API:令牌(操作) API:Info 获得编辑令牌。

参数

  • filename: 目标文件名,没有File:前缀。
  • archivename: 需要恢复的文件的目标版本,格式应包含该文件版本的时间戳以及文件名,形如:yyyyMMddhhmmss!filename。此处传递的信息可以通过iilimit设置大于1的Imageinfo接口请求得到。当浏览文件页面时,列表中显示的文件上传时间不会直接包含秒数;另外,文件名可以通过通过把光标悬停到旧的文件缩略图上获取。(另注意,通过此方法看到的文件名若包含!字符,它一般已经被解码为 %21
  • token: CSRF令牌可以通过上面的令牌一节所描述的方法获得,别忘记将末尾的+\转义为%2B%5C
  • comment: 上传摘要。

错误代码

除了通常情况之外:

代码 信息
missingtitle 您指定的页面不存在。
filerevert-badversion 文件并无所请求时间戳下的早期本地版本。

示例

将 Wiki.png 恢复为2011年3月5日 15:27:40 的版本。

结果
{
  "filerevert": {
    "result": "Success"
  }
}



action=filerevert

(main | filerevert)
  • This module requires read rights.
  • This module requires write rights.
  • This module only accepts POST requests.
  • Source: MediaWiki
  • License: GPL-2.0-or-later

Revert a file to an old version.

Specific parameters:
Other general parameters are available.
filename

Target filename, without the File: prefix.

This parameter is required.
comment

Upload comment.

Default: (empty)
archivename

Archive name of the revision to revert to.

This parameter is required.
token

A "csrf" token retrieved from action=query&meta=tokens

This parameter is required.