Postman发post请求读取不到文件的情况

使用Fdfs上传文件,postman发post请求读取不到文件,postman报错信息如下:

This file isn't in your working directory. Teammates you share this request with won't be able to use this file. To make collaboration easier you can setup your working directory in Settings.

解决方法
File-->Settings-->General-->WORKING DIRECTORY-->Choose-->选择工作目录,并把需要传输的文件放置该目录下。
在这里插入图片描述
  如果还有报错,不能识别设置的working directory,注意重启,重启解决不了问题,那么建议换postman版本,我是8.22.2不行,换了之前的老版本7点几的版本就好了。

  • 6
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
可以使用Java中的HttpURLConnection类来模拟PostmanPOST请求。具体步骤如下: 1. 创建URL对象,指定请求的URL地址。 2. 调用URL对象的openConnection()方法,获取HttpURLConnection对象。 3. 设置请求的方法为POST,调用setRequestMethod()方法。 4. 设置请求头,调用setRequestProperty()方法。 5. 设置请求体,调用getOutputStream()方法获取输出流,将请求参数写入输出流。 6. 请求,调用connect()方法。 7. 获取响应,调用getInputStream()方法获取输入流,读取响应数据。 8. 关闭连接,调用disconnect()方法。 示例代码如下: ``` import java.io.*; import java.net.*; public class PostRequestDemo { public static void main(String[] args) throws Exception { String url = "http://example.com/api"; String params = "param1=value1&param2=value2"; URL obj = new URL(url); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); // 设置请求方法为POST con.setRequestMethod("POST"); // 设置请求头 con.setRequestProperty("User-Agent", "Mozilla/5."); con.setRequestProperty("Accept-Language", "en-US,en;q=.5"); // 设置请求体 con.setDoOutput(true); OutputStream os = con.getOutputStream(); os.write(params.getBytes()); os.flush(); os.close(); // 请求 con.connect(); // 获取响应 BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); // 输出响应结果 System.out.println(response.toString()); // 关闭连接 con.disconnect(); } } ```
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值