mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-06-08 11:37:25 +00:00
upload
This commit is contained in:
parent
4f0badf168
commit
0a835eb025
2 changed files with 29 additions and 2 deletions
|
|
@ -41,6 +41,18 @@ async function generatePresignedUrls({
|
|||
return res.json() as Promise<{ url: string }>;
|
||||
}
|
||||
|
||||
// fetch sqs quess and show it in logs for testing purposes
|
||||
export async function fetchQueuesAndLog() {
|
||||
try {
|
||||
const res = await fetch("/db/surveyDB/api/show_all_sqs_available");
|
||||
if (!res.ok) throw new Error("Failed to fetch queues");
|
||||
const data = await res.json();
|
||||
console.log("✅ Available SQS queues:", data.queues);
|
||||
} catch (err) {
|
||||
console.error("❌ Error fetching queues:", err);
|
||||
}
|
||||
}
|
||||
|
||||
// Decide content-type from file extension
|
||||
function contentTypeFor(ext: string): string {
|
||||
const e = ext.toLowerCase();
|
||||
|
|
@ -128,7 +140,18 @@ export const UploadModal = ({ open, onClose, documentType, uprn }: UploadModalPr
|
|||
console.error("DB insert failed:", err);
|
||||
throw new Error("Failed to insert uploaded file record");
|
||||
}
|
||||
console.log("returned",res.json());
|
||||
const { id: db_id } = await res.json()
|
||||
console.log("db_id is ", db_id);
|
||||
// SQS list
|
||||
console.log("Sending request to sqs")
|
||||
|
||||
// enqueue only the id
|
||||
await fetch("/db/surveyDB/api/send_to_extractor_loader", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ id: db_id }), // 👈 only id
|
||||
});
|
||||
console.log(`sent request with ${db_id} check with aws sqs queue`);
|
||||
// Success — close the dialog and let parent refresh UI
|
||||
onClose();
|
||||
} catch (err) {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,11 @@ import {
|
|||
// If you prefer explicit creds via env, keep your current config;
|
||||
// otherwise, this ctor will use the default credential chain (env vars, shared profile, role, etc.)
|
||||
const sqsClient = new SQSClient({
|
||||
region: process.env.AWS_REGION,
|
||||
region: process.env.SQS_AWS_REGION,
|
||||
credentials: {
|
||||
accessKeyId: process.env.SQS_AWS_ACCESS_KEY_ID as string,
|
||||
secretAccessKey: process.env.SQS_AWS_SECRET_ACCESS_KEY as string,
|
||||
},
|
||||
});
|
||||
|
||||
let cachedQueueUrl: string | null = null;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue