Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

上传文件集合出现{"code":500,"statusText":"","message":"Invalid array length","data":null} #3458

Closed
qukuqhd opened this issue Dec 24, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@qukuqhd
Copy link

qukuqhd commented Dec 24, 2024

我在使用fastGpt的httpAPi上传文件集合时出现错误。

api 调用代码

package main

import (
"bytes"
"fmt"
"io/ioutil"
"mime/multipart"
"net/http"
)

func main() {
body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
writer.WriteField("data", { "datasetId" : "67403aed9dc72d22a59df1b4", "parentId" : null, "trainingType" : "qa", "chunkSize" : 0, "chunkSplitter" : "", "qaPrompt" : "", "metadata" : null })
part, e := writer.CreateFormFile("file", "aadas.txt")
if e != nil {
panic(e)
}
part.Write([]byte("内容内容"))
writer.Close()
r, e := http.NewRequest("POST", "http://ip和端口/api/core/dataset/collection/create/localFile", body)
if e != nil {
panic(e)
}
r.Header.Add("Content-Type", writer.FormDataContentType())
r.Header.Add("Authorization", "Bearer 密钥")
client := &http.Client{}
resp, e := client.Do(r)
if e != nil {
panic(e)
}
defer resp.Body.Close()
fmt.Println("response Status:", resp.Status)
all, err := ioutil.ReadAll(resp.Body)
if err != nil {
panic(err)
return
}
println(string(all))
}

@qukuqhd qukuqhd added the bug Something isn't working label Dec 24, 2024
@c121914yu
Copy link
Collaborator

什么版本?最新代码里没找到相关错误

@qukuqhd
Copy link
Author

qukuqhd commented Jan 7, 2025

以解决

@qukuqhd qukuqhd closed this as completed Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants