Coder Social home page Coder Social logo

Comments (10)

qicosmos avatar qicosmos commented on September 3, 2024

抓包看看二者哪里不同。

from cinatra.

wuyiwywy avatar wuyiwywy commented on September 3, 2024

py requests 传过去多了一个头信息,但是我其他的接口用这两种访问方式就没有这样的问题

from cinatra.

qicosmos avatar qicosmos commented on September 3, 2024

用node js传呢

from cinatra.

wuyiwywy avatar wuyiwywy commented on September 3, 2024

没用过node.js,主要最近用你推荐的file方式上传图片,写好整个项目,但是今天利用python调用接口发现py request上传的图片req.get_upload_files()获取不到
image

from cinatra.

qicosmos avatar qicosmos commented on September 3, 2024

你打包一个上传文件的测试程序给我,我看看。

from cinatra.

wuyiwywy avatar wuyiwywy commented on September 3, 2024

我用postman就可以正常上传图片,问题就是我最开始截图的那两个问题

from cinatra.

wuyiwywy avatar wuyiwywy commented on September 3, 2024

void process(request& req, response& res) {
auto& files = req.get_upload_files();
std::string img_path;
for (auto& file : files) {
std::cout << file.get_file_path() << " " << file.get_file_size() << std::endl;
img_path = file.get_file_path();
}
auto data = req.body();
std::cout << "body length:" << data<< std::endl;
}

from cinatra.

wuyiwywy avatar wuyiwywy commented on September 3, 2024

import base64
import requests
from urllib.parse import unquote

with open("../data/img/test1.png", "rb") as f:
img = f.read()

headers = {"Content-Type": "form-data"}
req_url = "http://127.0.0.1:8081/"
res = requests.post(req_url, headers=headers, files={"file": img})
print(res.text)

py 的测试程序

from cinatra.

wuyiwywy avatar wuyiwywy commented on September 3, 2024

要不我加你qq,截图给你看也行

from cinatra.

qicosmos avatar qicosmos commented on September 3, 2024

你加cinatra qq群吧 340713904

from cinatra.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.