Skip to content

相片管理 ​

相片接口只访问当前 Token 所属账号的相片。

获取相片列表 ​

http
POST /photo/get
json
{
  "token": "<TOKEN>"
}

响应:

json
{
  "success": true,
  "msg": "success",
  "fileList": ["photo_001.jpg", "photo_002.jpg"]
}

获取相片文件 ​

http
POST /photo/get-file
json
{
  "token": "<TOKEN>",
  "fileName": "photo_001.jpg"
}

成功时返回图片二进制;失败时通常返回 JSON:

json
{
  "success": false,
  "msg": "file not found"
}

JavaScript 示例 ​

js
const response = await fetch(`${API}/photo/get-file`, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ token, fileName }),
});

const type = response.headers.get('content-type') || '';
if (type.includes('application/json')) {
  throw new Error((await response.json()).msg || '读取相片失败');
}
const blob = await response.blob();

删除指定相片 ​

http
POST /photo/del-file
json
{
  "token": "<TOKEN>",
  "fileName": "photo_001.jpg"
}

删除全部相片 ​

http
POST /photo/del
json
{
  "token": "<TOKEN>"
}

删除操作不可逆。客户端应在调用前要求用户二次确认,并在 UI 中明确显示目标文件或“全部”。

Released under the CC BY-NC-SA 4.0 License.