-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dc3187b
commit 01b3561
Showing
4 changed files
with
79 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
export async function onRequest(context) { | ||
const { params, env } = context; | ||
|
||
console.log("Request ID:", params.id); | ||
|
||
// 获取元数据 | ||
const value = await env.img_url.getWithMetadata(params.id); | ||
console.log("Current metadata:", value); | ||
|
||
// 如果记录不存在 | ||
if (!value.metadata) return new Response(`Image metadata not found for ID: ${params.id}`, { status: 404 }); | ||
|
||
// 更新文件名 | ||
value.metadata.fileName = params.name; | ||
await env.img_url.put(params.id, "", { metadata: value.metadata }); | ||
|
||
console.log("Updated metadata:", value.metadata); | ||
|
||
return new Response(JSON.stringify({ success: true, fileName: value.metadata.fileName }), { | ||
headers: { 'Content-Type': 'application/json' }, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters