style: auto-fix linting issues
This commit is contained in:
parent
8c77b18073
commit
812178e3f3
1 changed files with 41 additions and 32 deletions
|
|
@ -67,16 +67,19 @@ export async function onRequest(context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uploadedFile.size > 500 * 1024 * 1024) {
|
if (uploadedFile.size > 500 * 1024 * 1024) {
|
||||||
return new Response(JSON.stringify({
|
return new Response(
|
||||||
error: 'File size exceeds 500MB limit',
|
JSON.stringify({
|
||||||
size: uploadedFile.size,
|
error: 'File size exceeds 500MB limit',
|
||||||
}), {
|
size: uploadedFile.size,
|
||||||
status: 400,
|
}),
|
||||||
headers: {
|
{
|
||||||
'Content-Type': 'application/json',
|
status: 400,
|
||||||
'Access-Control-Allow-Origin': '*',
|
headers: {
|
||||||
},
|
'Content-Type': 'application/json',
|
||||||
});
|
'Access-Control-Allow-Origin': '*',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
file = await uploadedFile.arrayBuffer();
|
file = await uploadedFile.arrayBuffer();
|
||||||
|
|
@ -162,28 +165,34 @@ export async function onRequest(context) {
|
||||||
|
|
||||||
const publicUrl = `https://i.imgur.gg/${fileInfo.fileId}-${fileInfo.fileName}`;
|
const publicUrl = `https://i.imgur.gg/${fileInfo.fileId}-${fileInfo.fileName}`;
|
||||||
|
|
||||||
return new Response(JSON.stringify({
|
return new Response(
|
||||||
success: true,
|
JSON.stringify({
|
||||||
url: publicUrl,
|
success: true,
|
||||||
fileId: fileInfo.fileId,
|
url: publicUrl,
|
||||||
fileName: fileInfo.fileName,
|
fileId: fileInfo.fileId,
|
||||||
}), {
|
fileName: fileInfo.fileName,
|
||||||
status: 200,
|
}),
|
||||||
headers: {
|
{
|
||||||
'Content-Type': 'application/json',
|
status: 200,
|
||||||
'Access-Control-Allow-Origin': '*',
|
headers: {
|
||||||
},
|
'Content-Type': 'application/json',
|
||||||
});
|
'Access-Control-Allow-Origin': '*',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return new Response(JSON.stringify({
|
return new Response(
|
||||||
error: 'Upload failed',
|
JSON.stringify({
|
||||||
message: error.message,
|
error: 'Upload failed',
|
||||||
}), {
|
message: error.message,
|
||||||
status: 500,
|
}),
|
||||||
headers: {
|
{
|
||||||
'Content-Type': 'application/json',
|
status: 500,
|
||||||
'Access-Control-Allow-Origin': '*',
|
headers: {
|
||||||
},
|
'Content-Type': 'application/json',
|
||||||
});
|
'Access-Control-Allow-Origin': '*',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue