generated from UoaWDCC/ssr-template
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
4 changed files
with
47 additions
and
33 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,25 @@ | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import type { APIRoute } from 'astro'; | ||
|
||
export const get: APIRoute = ({ params }) => { | ||
// Check if params.image is defined | ||
const imageParam = params.image as string; // Cast to string | ||
if (!imageParam) { | ||
return new Response('Image not specified', { status: 400 }); | ||
} | ||
|
||
const imagePath = path.join('data', 'members', imageParam); // Use the imageParam directly | ||
|
||
// Check if the image file exists | ||
if (fs.existsSync(imagePath)) { | ||
const imageBuffer = fs.readFileSync(imagePath); | ||
return new Response(imageBuffer, { | ||
headers: { | ||
'Content-Type': 'image/webp', // Adjust the content type as necessary | ||
}, | ||
}); | ||
} else { | ||
return new Response('Image not found', { status: 404 }); | ||
} | ||
}; |
This file was deleted.
Oops, something went wrong.
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