Skip to content

Commit

Permalink
add notice when picture has been deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
MarSeventh committed Sep 11, 2024
1 parent b8379f9 commit 585f9f5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 0 additions & 2 deletions functions/api/manage/delete/[id].js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ 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)
await env.img_url.delete(params.id);
const info = JSON.stringify(params.id);
return new Response(info);
Expand Down
5 changes: 4 additions & 1 deletion functions/file/[id].js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export async function onRequest(context) { // Contents of context object
}
const imgRecord = await env.img_url.getWithMetadata(params.id);
// 图片是否存在
if (imgRecord === null) {
if (imgRecord === null || imgRecord?.metadata === null) {
return new Response('Error: Image not found', { status: 404 });
}

Expand All @@ -49,6 +49,9 @@ export async function onRequest(context) { // Contents of context object
const fileType = imgRecord.metadata?.FileType || 'image/jpeg';

const response = await getFileContent(request, imgRecord, TgFileID, env, url);
if (response === null) {
return new Response('Error: Failed to fetch image', { status: 500 });
}

try {
const headers = new Headers(response.headers);
Expand Down
2 changes: 0 additions & 2 deletions functions/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,6 @@ export async function onRequestPost(context) { // Contents of context object
);
}
const time = new Date().getTime();
// const src = clonedRes[0].src;
// const id = src.split('/').pop();
const id = fileInfo.file_id;
const fullId = id + '.' + fileExt;
const apikey = env.ModerateContentApiKey;
Expand Down

0 comments on commit 585f9f5

Please sign in to comment.