将数据转二进制流文件,用PostMan发送二进制流请求

一、将byte数组转二进制流文件,并保存到本地

byte [] oneshotBytes=new byte[]{78,-29,51,-125,86,-105,56,82,-94,-115,-22,-105,0,-45,-48,-114,27,13,38,45,-24,-15,-13,46,88,-90,-66,-29,52,-23,40,-2,116,2,-115,17,36,15,-84,88,-72,22,-86,41,-90,-19,-58,19,99,-4,-63,29,51,-69,117,-120,121,3,-103,-75,44,64,-58,-34,73,-22,110,-90,92,-35,-18,-128,16,-36,41,23,-100,39,43,82,17,-64,62,-104,50,-72,71,68,50,-24,-75,-61,-15,-107,42,107,120,-48,41,81,9,-39,81,47,70,-63,-3,-54,69,-30,0,104,36,72,-57,67,-79,-67,-1,-64,-67,41,-99,-1,-60,-34,63,7,-104,99,-90,85,97,76,107,-124,79,39,-7,76,70,59,-126,98,9,102,3,122,7,66,10,-48,112,48,69,102,30,95,65,39,-9,88,109,-67,-29,-36,-11,86,-53,117,-68,96,-15,116,4,-69,115,53,35,30,115,-37,41,-75,119,-74,110,77,-116,-89,69,104,112,-22,-94,-84,-90,-90,-19,-121,-30,11,96,-125,-39,-114,-71,-123,27,68,-27,-85,72,-23,40,-100,33,107,88,-114,-118,-56,58,33,45,30,-119,-27,-58,111,-11,80,-111,-85,-10,120,-119,75,-10,1,71,-28,1,-26,50,-68,67,119,97,-41,-81,-7,-80,-17,-73,94,-61,65,-83,84,-16,70,-20,30,-91,-111,61,56,-99,113,0,50,-43,29,-81,-104,-90,81,-40,100,35,123,107,78,106,-61,38,-61,-124,78,25,-66,-16,-81,16,77,-88,58,-26,43,-50,28,-46,14,-75,76,64,-101,-26,92,-97,-106,-48,19,-6,-12,-102,91,42,-14,-26,95,50,67,113,-45,1,5,-98,118,-8,32,-74,-93,-66,0,99,-65,122,36,35,-53,-29,-116,50,19,-18,-14,-45,104,38,-47,79,-103,29,-44,-36,47,1,62,-12,-108,36,101,127,-19,63,15,-88,-85,97,-39,-26,-88,9,106,92,61,-109,-62,-96,-42,89,-123,-55,-69,76,-104,-20,24,-128,44,-76,-34,-85,40,-2,127,102,-100};

/**

* 创建File对象

*/

File file = new File(Environment.getExternalStorageDirectory(),

"test/streamFile");

// 创建FileOutputStream对象

FileOutputStream outputStream = null;

// 创建BufferedOutputStream对象

BufferedOutputStream bufferedOutputStream = null;

try {

// 如果文件存在则删除

if (file.exists()) {

file.delete();

}

// 根据路径创建一个新的空文件

file.createNewFile();

// 获取FileOutputStream对象

outputStream = new FileOutputStream(file);

// 获取BufferedOutputStream对象

bufferedOutputStream = new BufferedOutputStream(outputStream);

// 往文件所在的缓冲输出流中写byte数据

bufferedOutputStream.write(bytes);

// 输出流

bufferedOutputStream.flush();

} catch (Exception e) {

// 打印异常信息

e.printStackTrace();

} finally {

// 关闭创建的流对象

if (outputStream != null) {

try {

outputStream.close();

} catch (IOException e) {

e.printStackTrace();

}

}

if (bufferedOutputStream != null) {

try {

bufferedOutputStream.close();

} catch (Exception e2) {

e2.printStackTrace();

}

}

}

二、将二进制流文件从SDK卡中复制出来,打开postman:

①设置请求头,根据自己项目需要设置,注意Content-Type不要填写

②编辑发送内容,选择第一步生成的文件,如下:

相关推荐
小码哥说测试5 小时前
接口测试用例设计的关键步骤与技巧解析!
自动化测试·测试工具·jmeter·职场和发展·测试用例·接口测试·postman
awonw20 小时前
[java][框架]springMVC(1/2)
测试工具·postman
钱钱钱端1 天前
【压力测试】如何确定系统最大并发用户数?
自动化测试·软件测试·python·职场和发展·压力测试·postman
qq_433716951 天前
测试分层:减少对全链路回归依赖的探索!
自动化测试·软件测试·功能测试·测试工具·回归·pytest·postman
qq_433716951 天前
Postman断言与依赖接口测试详解!
自动化测试·软件测试·功能测试·测试工具·mysql·接口测试·postman
程序员雷叔2 天前
外包功能测试就干了4周,技术退步太明显了。。。。。
功能测试·测试工具·面试·职场和发展·单元测试·测试用例·postman
安冬的码畜日常2 天前
【玩转 Postman 接口测试与开发2_005】第六章:Postman 测试脚本的创建(上)
javascript·测试工具·单元测试·postman·bdd·chai
程序员小雷2 天前
应对自动化测试中的异步操作:策略与实践
功能测试·selenium·测试工具·jmeter·单元测试·测试用例·postman
Ven%2 天前
实用篇:postman汉化教程
测试工具·postman
钱钱钱端3 天前
UI自动化测试 —— CSS元素定位实践!
css·功能测试·selenium·测试工具·jmeter·ui·postman