diff --git a/functions/api/manage/block/[id].js b/functions/api/manage/block/[id].js index 864e2dd5..4ab7e7a2 100644 --- a/functions/api/manage/block/[id].js +++ b/functions/api/manage/block/[id].js @@ -8,12 +8,12 @@ export async function onRequest(context) { next, // used for middleware or to fetch assets data, // arbitrary space for passing data between middlewares } = context; - console.log(env) - console.log(params.id) + // 解码params.id + params.id = decodeURIComponent(params.id); + //read the metadata const value = await env.img_url.getWithMetadata(params.id); - console.log(value) - //"metadata":{"TimeStamp":19876541,"ListType":"None","rating_label":"None"} + //change the metadata value.metadata.ListType = "Block" await env.img_url.put(params.id,"",{metadata: value.metadata}); diff --git a/functions/api/manage/delete/[id].js b/functions/api/manage/delete/[id].js index 8d75b096..35f024a9 100644 --- a/functions/api/manage/delete/[id].js +++ b/functions/api/manage/delete/[id].js @@ -8,6 +8,9 @@ export async function onRequest(context) { next, // used for middleware or to fetch assets data, // arbitrary space for passing data between middlewares } = context; + // 解码params.id + params.id = decodeURIComponent(params.id); + await env.img_url.delete(params.id); const info = JSON.stringify(params.id); return new Response(info); diff --git a/functions/api/manage/white/[id].js b/functions/api/manage/white/[id].js index fed47448..628127fd 100644 --- a/functions/api/manage/white/[id].js +++ b/functions/api/manage/white/[id].js @@ -8,12 +8,12 @@ export async function onRequest(context) { next, // used for middleware or to fetch assets data, // arbitrary space for passing data between middlewares } = context; - console.log(env) - console.log(params.id) + // 解码params.id + params.id = decodeURIComponent(params.id); + //read the metadata const value = await env.img_url.getWithMetadata(params.id); - console.log(value) - //"metadata":{"TimeStamp":19876541,"ListType":"None","rating_label":"None"} + //change the metadata value.metadata.ListType = "White" await env.img_url.put(params.id,"",{metadata: value.metadata}); diff --git a/functions/file/[id].js b/functions/file/[id].js index a81d4e35..7b645806 100644 --- a/functions/file/[id].js +++ b/functions/file/[id].js @@ -9,7 +9,9 @@ export async function onRequest(context) { // Contents of context object next, // used for middleware or to fetch assets data, // arbitrary space for passing data between middlewares } = context; - + // 解码params.id + params.id = decodeURIComponent(params.id); + const url = new URL(request.url); let Referer = request.headers.get('Referer') if (Referer) { diff --git a/functions/upload.js b/functions/upload.js index 9a7b1eaf..31132880 100644 --- a/functions/upload.js +++ b/functions/upload.js @@ -163,7 +163,7 @@ export async function onRequestPost(context) { // Contents of context object const apikey = env.ModerateContentApiKey; if (apikey == undefined || apikey == null || apikey == "") { - await env.img_url.put(encodedFullId, "", { + await env.img_url.put(fullId, "", { metadata: { FileName: fileName, FileType: fileType, ListType: "None", Label: "None", TimeStamp: time, Channel: "TelegramNew", TgFilePath: filePath, TgFileId: id }, }); } else { @@ -173,7 +173,7 @@ export async function onRequestPost(context) { // Contents of context object throw new Error(`HTTP error! status: ${fetchResponse.status}`); } const moderate_data = await fetchResponse.json(); - await env.img_url.put(encodedFullId, "", { + await env.img_url.put(fullId, "", { metadata: { FileName: fileName, FileType: fileType, ListType: "None", Label: moderate_data.rating_label, TimeStamp: time, Channel: "TelegramNew", TgFilePath: filePath, TgFileId: id }, }); } catch (error) {