Skip to content

Commit

Permalink
sync(service): 新增获取随机图片api、可配置是否展示私有图
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Jan 17, 2025
1 parent 972e3f2 commit 281e387
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions service/src/controllers/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -500,14 +500,15 @@ export async function handleGetImage(request, env) {

const { metadata } = await env.CYI_IMGKV.getWithMetadata(randomImage.id);

// 直接返回图片数据和响应头
return new Response(imageData, {
// 返回与 handleGetImage 相同的格式
return {
body: imageData,
headers: {
'Content-Type': metadata.mimeType || 'application/octet-stream',
'Content-Disposition': `inline; filename="${metadata.filename || 'unknown.png'}"`,
'Cache-Control': CONFIG.CACHE_CONTROL,
},
});
};

} catch (error) {
console.error('Error fetching random image:', error);
Expand Down

0 comments on commit 281e387

Please sign in to comment.