fix: allow larger file uploads
This commit is contained in:
@@ -15,27 +15,14 @@
|
||||
|
||||
async function uploadStudySpace() {
|
||||
const imageFile = fileInput?.files?.[0];
|
||||
const imageB64 = imageFile
|
||||
? await new Promise<string>((resolve) => {
|
||||
const reader = new FileReader();
|
||||
reader.onload = () => resolve(reader.result as string);
|
||||
reader.readAsDataURL(imageFile);
|
||||
})
|
||||
: null;
|
||||
if (!imageB64 || !imageFile) {
|
||||
if (!imageFile) {
|
||||
alert("Please select an image file.");
|
||||
return;
|
||||
}
|
||||
const res = await fetch("/api/study_spaces", {
|
||||
const params = new URLSearchParams({ title, imgTitle: imageFile.name });
|
||||
const res = await fetch(`/api/study_spaces?${params.toString()}`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
title,
|
||||
img: imageB64,
|
||||
imgTitle: imageFile.name
|
||||
})
|
||||
body: imageFile
|
||||
});
|
||||
if (res.ok) {
|
||||
alert("Study space uploaded successfully!");
|
||||
|
||||
Reference in New Issue
Block a user