Flowise icon indicating copy to clipboard operation
Flowise copied to clipboard

External Post call to upsert API with form data doesn't replace or add file

Open Sdegraauw opened this issue 1 year ago • 3 comments

Describe the bug External Post call done in ASP.net to the upsert API done with MultipartFormDataContent doesn't replace or add file. the upsert does happen but with the file that was uploaded in the chatflow edditor.

To Reproduce

  1. upload file into an IFormFile in ASP.

  2. use the folowing function to do the post request: [HttpPost] public async Task<IActionResult> Index(IFormFile file) {

    HttpClient client = new HttpClient(); using (var content = new MultipartFormDataContent()) { byte[] fileBytes = new byte[file.OpenReadStream().Length]; await file.OpenReadStream().ReadAsync(fileBytes, 0, (int)file.OpenReadStream().Length); ByteArrayContent bytes = new ByteArrayContent(fileBytes);

     content.Add(bytes, "files", file.FileName);
     Console.WriteLine(await content.ReadAsStringAsync());
    
     var response = await client.PostAsync("http://localhost:3000/api/v1/vector/upsert/fe443d55-fdde-4c6d-88f6-1c40d14c49e3", content);
     var responseString = await response.Content.ReadAsStringAsync();
    
     Console.WriteLine(responseString);
    

    }

    return View(); }

Expected behavior an upsert response with the data from the uploaded file should be printed in console.

Screenshots old new new Controler method

Flow Faiss Chatflow (1).json

Setup

  • Installation npx flowise start --DEBUG=true
  • Flowise Version 1.8.0
  • OS: Windows 10
  • chrome

Sdegraauw avatar Jun 06 '24 12:06 Sdegraauw

not sure if this is related to the ASP.net code, but if you try using Python or Postman to make the calls, it should work: https://docs.flowiseai.com/using-flowise/api#document-loaders-with-upload

HenryHengZJ avatar Jun 12 '24 21:06 HenryHengZJ

描述在 ASP.net 中对使用 MultipartFormDataContent 完成的 upsert API 进行的外部发布调用的错误 ,不会替换或添加文件。upsert 确实发生了,但使用的是 chatflow 编辑器中上传的文件。

复制

  1. 将文件上传到 ASP 中的 IFormFile 中。

  2. 使用以下函数执行发布请求: [HttpPost] public async Task Index(IFormFile file) { HttpClient 客户端 = new HttpClient(); 使用(var content = new MultipartFormDataContent()) { byte[] fileBytes = new byte[file.OpenReadStream().Length]; 等待 file.OpenReadStream().ReadAsync(fileBytes, 0,(int)file.OpenReadStream().Length); ByteArrayContent 字节 = new ByteArrayContent(fileBytes);

     content.Add(bytes, "files", file.FileName);
     Console.WriteLine(await content.ReadAsStringAsync());
    
     var response = await client.PostAsync("http://localhost:3000/api/v1/vector/upsert/fe443d55-fdde-4c6d-88f6-1c40d14c49e3", content);
     var responseString = await response.Content.ReadAsStringAsync();
    
     Console.WriteLine(responseString);
    

    } 返回视图(); }

预期行为是, 应在控制台中打印包含上传文件数据的 upsert 响应。

截图 老的 新的 新的 控制方法

**Flow ** Faiss Chatflow (1).json

设置

  • 安装npx flowise start --DEBUG=true
  • Flowise 版本 1.8.0
  • 操作系统:Windows 10
  • 铬合金

same problem!!!!

Yakiw avatar Jul 15 '24 01:07 Yakiw

描述在 ASP.net 中对使用 MultipartFormDataContent 完成的 upsert API 进行的外部发布调用的错误 ,不会替换或添加文件。upsert 确实发生了,但使用的是 chatflow 编辑器中上传的文件。

复制

  1. 将文件上传到 ASP 中的 IFormFile 中。

  2. 使用以下函数执行发布请求: [HttpPost] public async Task Index(IFormFile file) { HttpClient 客户端 = new HttpClient(); 使用(var content = new MultipartFormDataContent()) { byte[] fileBytes = new byte[file.OpenReadStream().Length]; 等待 file.OpenReadStream().ReadAsync(fileBytes, 0,(int)file.OpenReadStream().Length); ByteArrayContent 字节 = new ByteArrayContent(fileBytes);

     content.Add(bytes, "files", file.FileName);
     Console.WriteLine(await content.ReadAsStringAsync());
    
     var response = await client.PostAsync("http://localhost:3000/api/v1/vector/upsert/fe443d55-fdde-4c6d-88f6-1c40d14c49e3", content);
     var responseString = await response.Content.ReadAsStringAsync();
    
     Console.WriteLine(responseString);
    

    } 返回视图(); }

预期行为是, 应在控制台中打印包含上传文件数据的 upsert 响应。

截图 老的 新的 新的 控制方法

**Flow ** Faiss Chatflow (1).json

设置

  • 安装npx flowise start --DEBUG=true
  • Flowise 版本 1.8.0
  • 操作系统:Windows 10
  • 铬合金

have u solved this problem?

Yakiw avatar Jul 15 '24 04:07 Yakiw

We have 2 new APIs that should solve the problemn: https://docs.flowiseai.com/using-flowise/api#document-upsert-refresh-api

HenryHengZJ avatar Dec 12 '24 02:12 HenryHengZJ