Skip to content

文件

重命名文件

1.接口说明

接口路径:/efile/openapi/v2/file/rename

请求方式:POST

请求数据类型:application/x-www-from-urlencoded

接口描述:重命名文件

2.请求消息

请求参数:

Headers:

名称类型必填描述示例
tokenstring接口凭证eyJhbGciOiJIUzI1N...

参数:

名称类型必填描述示例
fileAbsolutePathstring源文件绝对路径/home/demo/efile-test/test.txt
newNamestring文件修改后的新名称test-1.txt

3.请求示例

cURL请求示例

shell
curl --location 'https://scnet-demo.accloud.cn/efile/openapi/v2/file/rename' \
--header 'token: <Token>' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'fileAbsolutePath=/home/demo/efile-test/test.txt' \
--data-urlencode 'newName=test-1.txt'

Java请求示例

java
import okhttp3.*;

public class FileRenameDemo {

    public static final String TOKEN = "<Token>";
    
    public static final String URL = "https://scnet-demo.accloud.cn/efile/openapi/v2/file/rename";

    public static void main(String[] args) throws Exception {
        OkHttpClient client = new OkHttpClient().newBuilder()
			.build();
		MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
		RequestBody body = RequestBody.create(mediaType, "fileAbsolutePath=/home/demo/efile-test/test.txt&newName=test-1.txt");
		Request request = new Request.Builder()
			.url(URL)
			.method("POST", body)
			.addHeader("token", TOKEN)
			.addHeader("Content-Type", "application/x-www-form-urlencoded")
			.build();
		Response response = client.newCall(request).execute();
		System.out.println(response.body().string());
    }
}

Python请求示例

python
import requests

url = "https://scnet-demo.accloud.cn/efile/openapi/v2/file/rename"
payload = "fileAbsolutePath=%2Fhome%2Fdemo%2Fefile-test%2Ftest.txt&newName=test-1.txt"
headers = {
  "token": "<Token>",
  "Content-Type": "application/x-www-form-urlencoded"
}

response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)

4.响应消息

返回参数:

名称类型说明
msgstring异常时的详细异常信息
codestring0:成功,10003:参数异常,911031:重命名失败,911700:文件名包含非法字符,911020:文件不存在,911021:文件已存在,911009:区域用户不存在,911030:权限不足,10001:其它异常
dataobject

返回示例:

json
{
  "code":"0",
  "data":null,
  "msg":"success"
}

5.错误码

错误码说明
0成功
10001内部异常(其他异常)
10003参数不全
10004参数无效
10009不支持的版本
911009区域用户不存在
911020文件不存在
911021文件已存在
911022目标地址不是一个文件夹
911025分享文件已存在,请重命名后分享
911029文件路径包含特殊字符,请重命名后再操作
911030权限不足,禁止操作
911031文件重命名失败
911034分享链接创建失败,请重新分享
911404ac认证服务端连接异常
911406服务端token认证异常,未取到关联用户
911501存储空间不足
911502目录非空,操作失败
911504命令执行超时
911505文件大小超出预设大小,无法预览
911506文件类型不在预设范围内,不允许打开
911507源文件与目标文件一致,禁止操作
911700文件名包含非法字符,请重命名后再操作