mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-06-30 12:55:02 +00:00
due considerations frontend functonality mostly done - trigger update with new aws keys
This commit is contained in:
parent
fd7c1578ef
commit
93ea63930d
2 changed files with 38 additions and 1 deletions
|
|
@ -45,7 +45,7 @@ export async function POST(request: NextRequest) {
|
|||
})
|
||||
);
|
||||
|
||||
return new NextResponse(JSON.stringify({ url: preSignedUrls }), {
|
||||
return new NextResponse(JSON.stringify({ urls: preSignedUrls }), {
|
||||
status: 200,
|
||||
});
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,43 @@ import { useState } from "react";
|
|||
import { SelectFolder } from "../components/due-considerations/SelectFolder";
|
||||
import { Button } from "../shadcn_components/ui/button";
|
||||
|
||||
async function uploadDueConsiderationFiles(files: File[]) {
|
||||
// Steps:
|
||||
// 1) For each file, generate a presigned url
|
||||
// 2) For each file, upload the file to the presigned url
|
||||
// 3) Trigger the due considerations process
|
||||
// 4) Profit????
|
||||
|
||||
// Step 1: Generate presigned URLs
|
||||
const response = await fetch("/path/to/your/api/endpoint", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
files: files.map((file) => ({
|
||||
fileKey: "your/folder/structure/" + file.name, // replace with your actual folder structure
|
||||
contentType: file.type,
|
||||
})),
|
||||
}),
|
||||
});
|
||||
|
||||
const { urls } = await response.json();
|
||||
|
||||
// Step 2: Upload files to S3
|
||||
await Promise.all(
|
||||
files.map((file, index) => {
|
||||
return fetch(urls[index], {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"Content-Type": file.type,
|
||||
},
|
||||
body: file,
|
||||
});
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
export default function DueConsiderationsHome() {
|
||||
const [files, setFile] = useState<File[]>([]);
|
||||
const [buttonDisabled, setButtonDisabled] = useState(true);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue