Skip to content

获取文件访问AK

接口信息

接口地址:/api/v1/file/ak

请求方式:GET

请求数据类型:

响应数据类型:*/*

接口描述:

获取文件的临时访问链接(带 AK 签名),用于访问私有存储的文件

请求示例:

GET /api/v1/file/ak?fileUrl=https://agent-statics-tc.nuwax.com/tmp/xxx.txt

请求参数

请求头

参数名类型必填描述示例值
AuthorizationstringAPI KeyBearer ak-xxxxeyJhbGciOiJIUzI1NiJ9

查询参数:

参数名称参数说明是否必须数据类型
fileUrl文件URLstring

响应参数:

参数名称参数说明类型schema
code业务状态码,0000 表示成功,其余失败string
displayCode源系统状态码,用于问题跟踪string
message错误描述信息string
data带签名的文件访问URLstring
tid跟踪唯一标识string
successboolean

响应示例:

javascript
{
	"code": "0000",
	"displayCode": "0000",
	"message": "success",
	"data": "https://agent-statics-tc.nuwax.com/tmp/f7dce62d43d142559772c0bd01b20e36.txt",
	"tid": "9542251776087397235",
	"success": true
}

CURL示例

shell
curl 'http://127.0.0.1:8081/api/v1/file/ak?fileUrl=https://agent-statics-tc.nuwax.com/tmp/f7dce62d43d142559772c0bd01b20e36.txt' \
  -H 'Authorization: Bearer ak-d1f2129c4ba24629b8448af3354f9dd0'

{"code":"0000","displayCode":"0000","message":"success","data":"https://...","tid":"9542251776087397235","success":true}

TS模板示例

ts
// 响应接口
export interface FileAkRes {
  code: string;
  displayCode: string;
  message: string;
  data: string;
  tid: string;
  success: boolean;
}

/** 
 * 获取文件访问AK(带签名的临时访问链接)
 * @param {string} fileUrl - 文件URL
 * @returns
 */
export function getFileAk(fileUrl: string): Promise<FileAkRes> {
  return request.get(`/api/v1/file/ak?fileUrl=${encodeURIComponent(fileUrl)}`);
}