Obi
Obi

Reputation: 303

Upload document into Flowise AI via API endpoint

I have an OpenSAAS (react) application, and a Flowise flow with document uploader and Supabase vector store. The chatbot is currently embedded on the website just fine. I added an upload button for uploading documents to the document loader & then upserted into Supabase. When I try to upload a file by 'fetching' to the upsert endpoint, it never uploads, always returning this object

{
    "numAdded": 0,
    "numDeleted": 0,
    "numUpdated": 0,
    "numSkipped": 0,
    "totalKeys": 0,
    "addedDocs": []
}.

Here's my code for reference

const metadata = {
      user_id: user.id,
      filename: fileName,
      created_date: fileCreatedDate,
      file_size: fileSize
    }

    let formData = new FormData();
    formData.append("files", event.target.files[0])
    formData.append("supabaseApiKey", SUPABASE_API_KEY ?? '')
    formData.append("supabaseProjUrl", SUPABASE_URL ?? '')
    formData.append("tableName", "documents")
    formData.append("metadata", JSON.stringify(metadata))

    return await fetch("blahblahblah/api/v1/vector/upsert/flowisekey", {
      method: 'POST',
      body: formData
    }).then(
      response => response.json() 
    ).then(
      success => {console.log(success); return "success"}
    ).catch(
      error => console.log(error) // Handle the error response object
    );

Any idea why it doesn't work? Any suggestions? Maybe I'm missing something.

Upvotes: 0

Views: 304

Answers (0)

Related Questions