第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會有你想問的

轉(zhuǎn)到 http:從 Qt 客戶端發(fā)送圖像后沒有這樣的文件

轉(zhuǎn)到 http:從 Qt 客戶端發(fā)送圖像后沒有這樣的文件

Go
胡子哥哥 2021-12-07 16:44:13
我有一個(gè) Go API,它應(yīng)該保存客戶端發(fā)送的圖像。我知道當(dāng) POST 請求來自 HTML 表單時(shí),Go 代碼有效。但是,當(dāng)從我的 Qt C++ 客戶端發(fā)送多部分發(fā)布請求時(shí),服務(wù)器返回錯(cuò)誤http: 沒有這樣的文件在客戶端,我有一個(gè) QPixmap,我將其轉(zhuǎn)換為 QByteArray,然后發(fā)送,但不知何故我從 Go 中得到了該錯(cuò)誤。我知道當(dāng)我刪除時(shí)客戶端發(fā)送的數(shù)據(jù)長度減少multi_part->append(image_part);所以應(yīng)該發(fā)送 QPixmap。去代碼:func apiUploadHandler(w http.ResponseWriter, req *http.Request) {if req.Method == "POST" {    req.ParseMultipartForm(0)    fmt.Printf("%v %v %v", req.RemoteAddr, req.ContentLength, req.Body)    file, fileheader, err := req.FormFile("image")    if err != nil {        cio.PrintMessage(1, err.Error())        return    }    defer file.Close()    var id string    created := false    for created != true {        id = generateImageID()        err = db.CheckIfImageIDInUse(id)        if err != nil {            if err.Error() == "Image ID '"+id+"' exists.'" {                created = false                continue            } else {                created = false                cio.PrintMessage(1, err.Error())                return            }        }        created = true    }    filePath := fsys.ImgStoragePath + id + "." + strings.Split(fileheader.Filename, ".")[1]    err = db.StoreImage(id, strings.Split(fileheader.Filename, ".")[0] /*image name*/, filePath, strings.Split(fileheader.Filename, ".")[1] /*extension*/)    if err != nil {        cio.PrintMessage(1, err.Error())        return    }    bytesCopied, err := fsys.StoreImage(filePath, file)    if err != nil {        cio.PrintMessage(1, err.Error())        return    }    cio.PrintMessage(0, "File "+filePath+" has been created.")    if err != nil {        cio.PrintMessage(1, err.Error())        return    }    cio.PrintMessage(0, "Content of uploaded image ("+strconv.FormatInt(bytesCopied, 10)+" Bytes) has been copied to "+filePath+".")    http.Redirect(w, req, "/"+id, http.StatusFound)}}
查看完整描述

1 回答

?
慕的地10843

TA貢獻(xiàn)1785條經(jīng)驗(yàn) 獲得超8個(gè)贊

我不確定,但你可以嘗試改變

image_part.setHeader(QNetworkRequest::ContentDispositionHeader,  QVariant("form-data; name=\"image\""));

image_part.setHeader(QNetworkRequest::ContentDispositionHeader,  QVariant("form-data; name=\"image\"; filename=\"Screenshot.png\""));



查看完整回答
反對 回復(fù) 2021-12-07
  • 1 回答
  • 0 關(guān)注
  • 166 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號