Finallyyyyyy finished the whole Speaking flow along with the solution page
This commit is contained in:
@@ -4,19 +4,23 @@ import {withIronSessionApiRoute} from "iron-session/next";
|
||||
import {sessionOptions} from "@/lib/session";
|
||||
import {getDownloadURL, getStorage, ref} from "firebase/storage";
|
||||
import {app} from "@/firebase";
|
||||
import axios from "axios";
|
||||
|
||||
// export default withIronSessionApiRoute(handler, sessionOptions);
|
||||
export default handler;
|
||||
export default withIronSessionApiRoute(handler, sessionOptions);
|
||||
|
||||
async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
// if (!req.session.user) {
|
||||
// res.status(401).json({ok: false});
|
||||
// return;
|
||||
// }
|
||||
if (!req.session.user) {
|
||||
res.status(401).json({ok: false});
|
||||
return;
|
||||
}
|
||||
|
||||
const storage = getStorage(app);
|
||||
const {path} = req.body as {path: string};
|
||||
|
||||
const pathReference = ref(storage, path);
|
||||
getDownloadURL(pathReference).then((url) => res.status(200).json({url}));
|
||||
const url = await getDownloadURL(pathReference);
|
||||
|
||||
const response = await axios.get(url, {responseType: "arraybuffer"});
|
||||
|
||||
res.status(200).send(response.data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user