From db70aec690c25a98a2174cfb4bb1b6b355fd2afb Mon Sep 17 00:00:00 2001 From: dreamisdream <48316419+dreamisdream@users.noreply.github.com> Date: Thu, 4 Aug 2022 10:15:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0webapi=20deleteRecordDirectro?= =?UTF-8?q?y(=E5=88=A0=E9=99=A4=E5=BD=95=E5=83=8F=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=A4=B9)=20(#1851)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- postman/ZLMediaKit.postman_collection.json | 46 ++++++++++++++++++++++ server/WebApi.cpp | 18 ++++++++- 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/postman/ZLMediaKit.postman_collection.json b/postman/ZLMediaKit.postman_collection.json index 6a0ea56d..201a621e 100644 --- a/postman/ZLMediaKit.postman_collection.json +++ b/postman/ZLMediaKit.postman_collection.json @@ -945,6 +945,52 @@ }, "response": [] }, + { + "name": "删除录像文件夹(deleteRecordDirectroy)", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{ZLMediaKit_URL}}/index/api/deleteRecordDirectroy?secret={{ZLMediaKit_secret}}&vhost={{defaultVhost}}&app=proxy&stream=2&period=2020-01-01", + "host": [ + "{{ZLMediaKit_URL}}" + ], + "path": [ + "index", + "api", + "deleteRecordDirectroy" + ], + "query": [ + { + "key": "secret", + "value": "{{ZLMediaKit_secret}}", + "description": "api操作密钥(配置文件配置),如果操作ip是127.0.0.1,则不需要此参数" + }, + { + "key": "vhost", + "value": "{{defaultVhost}}", + "description": "虚拟主机,例如__defaultVhost__" + }, + { + "key": "app", + "value": "proxy", + "description": "应用名,例如 live" + }, + { + "key": "stream", + "value": "2", + "description": "流id,例如 test" + }, + { + "key": "period", + "value": "2020-01-01", + "description": "流的录像日期,格式为2020-01-01,如果不是完整的日期,那么会删除失败" + } + ] + } + }, + "response": [] + }, { "name": "开始录制(startRecord)", "request": { diff --git a/server/WebApi.cpp b/server/WebApi.cpp index b5863215..bd72ffc1 100755 --- a/server/WebApi.cpp +++ b/server/WebApi.cpp @@ -1332,7 +1332,23 @@ void installWebApi() { invoker(200, headerOut, val.toStyledString()); }); }); - + + // 删除录像文件夹 + // http://127.0.0.1/index/api/deleteRecordDirectroy?vhost=__defaultVhost__&app=live&stream=ss&period=2020-01-01 + api_regist("/index/api/deleteRecordDirectroy", [](API_ARGS_MAP) { + CHECK_SECRET(); + CHECK_ARGS("vhost", "app", "stream"); + auto record_path = Recorder::getRecordPath(Recorder::type_mp4, allArgs["vhost"], allArgs["app"], allArgs["stream"], allArgs["customized_path"]); + auto period = allArgs["period"]; + record_path = record_path + period + "/"; + int result = File::delete_file(record_path.data()); + if(!result) { + record_path = "delete error"; + } + val["code"] = result; + val["path"] = record_path.data(); + }); + //获取录像文件夹列表或mp4文件列表 //http://127.0.0.1/index/api/getMp4RecordFile?vhost=__defaultVhost__&app=live&stream=ss&period=2020-01 api_regist("/index/api/getMp4RecordFile", [](API_ARGS_MAP){