Comments (1)
@hyhy01 @icret Holy shit, I got it working in uPic.
You have to specify Content-Type
as multipart/form-data
in request header. Otherwise, it will send the data, including the file, as pure JSON.
The following is my debug journey and postmortem:
First, I checked nginx log to make sure that the server is getting the request. And that's a check.
Then I want to see what the server returns to uPic like so:
I tried to search for uPic logs, but I couldn't find its log file, nor any marks in system logs.
So I decided to capture the network traffic with tcpdump
, then use Wireshark to analyze the traffic.
There, I can see that easyimage server sends the following message back to uPic:
{
"result": "failed",
"code": 204,
"message": "没有选择上传的文件"
}
Hmmm, interesting.
Then I analyzed traffic from curl
and Postman as well for comparison.
There I can see that, both curl
and Postman is sending the request as type multipart/form-data
, while uPic is doing that via application/json
, which is a sub-type of html/text
.
Aha! I was like, WHAT?! uPic, how dare you send a file via json
.
这件事对于开发人员的经验/教训:
- When sending a file, never forget to attach header
Content-type: multipart/form-data
to the request. For form submission, browser will auto specify the correctContent-type
, but in REST/Ajax calls, we developers have to manually specify the correctContent-type
for use. - @icret At this moment, easyimage is returning HTTP status code 200 (OK) in the above situation, I believe it is more appropriate to return 400 (Bad Request) instead. With that, apps like uPic will be able to properly detect and handle the error, and probably show an error popup to inform its user.
from easyimages2.0.
Related Issues (20)
- 广场显示所有上传的图片 HOT 1
- 使用api上传提示204错误 HOT 1
- 如何修改为无视单文件上传100M的限制?
- 关于验证码在php8.0环境下显示不出来问题 HOT 1
- Feat|>希望能添加docker部署 HOT 3
- 我反向代理了端口,显示界面出错
- TinyFileManage无法正常使用
- 希望支持docker HOT 1
- Mixed Content Issue When Accessing Resources Over HTTPS HOT 2
- edge浏览器,首页上传的粘贴功能无效 HOT 1
- 2.0版本安装环境监测时遇到问题 HOT 4
- 怎么获取最近上传的图片URL? HOT 1
- 输入账号密码后点击登录,总是回跳到登录页面
- API说明文档中python示例测试不成功,payload参数应该怎么设定? HOT 1
- 不知道为什么PHP搭建的项目总是被挖矿 HOT 2
- 查看已经上传图像的链接 HOT 1
- 隐藏存储路径不生效 HOT 7
- 登录重复跳转问题 HOT 2
- 求求求!!!后台删除图片了还能显示, HOT 1
- 安装完之后主页出现的错误提示
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from easyimages2.0.