当前位置: 首页 > news >正文

在网站上做承诺书泉州百度竞价开户

在网站上做承诺书,泉州百度竞价开户,芜湖做网站公司,wordpress 自定义模板一、何为base64加密版pdf文件 如下图所示,接口jmeter执行后,返回一串包含大小写英文字母、数字、、/、的长字符串,直接另存为pdf文件后,文件有大小,但是打不开;另存为doc文件后,打开可以看到和…

一、何为base64加密版pdf文件

如下图所示,接口jmeter执行后,返回一串包含大小写英文字母、数字、+、/、=的长字符串,直接另存为pdf文件后,文件有大小,但是打不开;另存为doc文件后,打开可以看到和接口响应一致的长字符串。

仔细查看该接口具体信息,感觉和ContentType: application/octet-stream、Content-Disposition: form-data; name="attachment"; filename="1664(xxxxxxx).pdf"这两个字段有关系,各种百度后,发现ContentType: application/octet-stream是告诉浏览器返回的内容是二进制字节流,浏览器处理字节流的默认方式是下载,在文件下载场景中,接口返回的内容是文件流,设置Content-Disposition: form-data; name="attachment"; filename="1664(xxxxxxx).pdf"后,浏览器会进行下载,且下载的文件名称为 1664(xxxxxxx).pdf。


Application/octet-stream是应用程序文件的默认值。意思是未知的应用程序文件,浏览器一般不会自动执行或询问执行。浏览器会像对待,设置了HTTP头Content-Disposition值为attachment的文件一样来对待这类文件,即浏览器会触发下载行为。

参考的链接:application/octet-stream-CSDN博客、HTTP请求头Content-Type总结说明_content-type: application/octet-stream-CSDN博客

从上可知,接口返回后浏览器需要进行一些操作,若想jmeter直接将响应另存为文件,百度了下可以添加BeanShell PostProcessor组件,获取接口响应结果,另存为pdf文件,结果另存的pdf文件打不开,但是显示大小为480KB,这是为啥呢?

接口响应这么一长串字符串,百度百度,感觉该长字符串是base64加密了,向开发确认后,开发提供了一个在线base64编码转pdf的网页,第一次将响应内容粘贴进去,点击查看pdf后,看不到pdf文件,将长字符串两端的双引号删除后,再次点击查看pdf后,pdf显示正常了;在线base64编码转pdf的网页链接如下:Base64 to PDF | Base64 Decode | Base64 Converter | Base64Convert Base64 to PDF online using a free decoding toolicon-default.png?t=N7T8https://base64.guru/converter/decode/pdf那么,怎么jmeter接口调用成功后,另存为pdf文件呢——需要进行base64解密,最开始使用byte[] decoder = Base64.getDecoder().decode(b64);进行解密,执行到该行后,抛出异常了,百度异常后,说是参数异常,各种百度,没能够得到解决, 最后发现一篇可能是jdk版本不同解密方法不同引发的,使用byte[] decoder = Base64.getMimeDecoder().decode(b64)试试看,哇我解密成功,另存的pdf打开正常。

参照的链接:application/octet-stream-CSDN博客

二、base64解密另存为pdf文件

如下图所示,在需要下载pdf文件的接口下,添加BeanShell PostProcessor组件,获取接口响应结果,进行base64解密后,另存为pdf文件。

如上图所示,点击右上角的log面板图标,可以打开log面板,log.info、log.error可以给jmeter log面板输出自己需要显示的调试信息,以便调试代码,具体的代码如下。

import java.io.File;
import java.util.Base64;
import java.io.FileOutputStream;//获取接口响应结果
//String responseData = prev.getResponseDataAsString();
byte[] responseData1 = prev.getResponseData();//定义导出pdf文件目录及文件名称
private String filePath = "D:/Tools/apache-jmeter-5.4.1/workspace/导出-${index}.pdf"; 
File file = new File(filePath);
FileOutputStream fos = new FileOutputStream(file);
try {//log.info("----------1------------");//log.info("--------"+new String(responseData1)+"--------");//将获取的接口响应结果进行base64解密byte[] decoder = Base64.getMimeDecoder().decode(responseData1);//log.info("----------2------------");//将解密结果写入pdf文件fos.write(decoder);//log.info("-------PDF File Saved---------");
} catch (Exception e) {log.error("------error------------",e);
} finally {if (fos != null) {fos.close();fos = null;}
}


文章转载自:
http://dinncoapograph.tqpr.cn
http://dinncodecuplet.tqpr.cn
http://dinncodoe.tqpr.cn
http://dinncosclerotize.tqpr.cn
http://dinncothessalonian.tqpr.cn
http://dinncoboltoperated.tqpr.cn
http://dinncostomatology.tqpr.cn
http://dinncowarhawk.tqpr.cn
http://dinncorevelator.tqpr.cn
http://dinncopawnshop.tqpr.cn
http://dinncowithdrew.tqpr.cn
http://dinncocythera.tqpr.cn
http://dinncopolysorbate.tqpr.cn
http://dinncoisaiah.tqpr.cn
http://dinncoecdysis.tqpr.cn
http://dinncodeferent.tqpr.cn
http://dinncoimaginational.tqpr.cn
http://dinncoaorist.tqpr.cn
http://dinncounselfishness.tqpr.cn
http://dinncoagress.tqpr.cn
http://dinncocraniometry.tqpr.cn
http://dinncowaiter.tqpr.cn
http://dinncoxenocurrency.tqpr.cn
http://dinncogushing.tqpr.cn
http://dinncovitruvian.tqpr.cn
http://dinncomanutius.tqpr.cn
http://dinncopsychognosy.tqpr.cn
http://dinncosucculently.tqpr.cn
http://dinncocreepage.tqpr.cn
http://dinncodcvo.tqpr.cn
http://dinncocorolliform.tqpr.cn
http://dinncopenalize.tqpr.cn
http://dinncosolifidian.tqpr.cn
http://dinncosensum.tqpr.cn
http://dinncopicromerite.tqpr.cn
http://dinncoguanethidine.tqpr.cn
http://dinncounfasten.tqpr.cn
http://dinncojaguarundi.tqpr.cn
http://dinncoimparl.tqpr.cn
http://dinncoantienergistic.tqpr.cn
http://dinncosubcollege.tqpr.cn
http://dinncodemonstrate.tqpr.cn
http://dinncoallocable.tqpr.cn
http://dinncodelitescent.tqpr.cn
http://dinncoprecancel.tqpr.cn
http://dinncoephemeralization.tqpr.cn
http://dinncochatelain.tqpr.cn
http://dinncopanelist.tqpr.cn
http://dinncocoursing.tqpr.cn
http://dinncodyarchy.tqpr.cn
http://dinncomultitudinal.tqpr.cn
http://dinncocrayonist.tqpr.cn
http://dinncophytogeny.tqpr.cn
http://dinncoallyl.tqpr.cn
http://dinncomonosign.tqpr.cn
http://dinncocrooner.tqpr.cn
http://dinncochastisement.tqpr.cn
http://dinncocoil.tqpr.cn
http://dinncoganglia.tqpr.cn
http://dinncoethnics.tqpr.cn
http://dinncounneighbourly.tqpr.cn
http://dinnconumismatology.tqpr.cn
http://dinncocongregation.tqpr.cn
http://dinncodentin.tqpr.cn
http://dinncocommissural.tqpr.cn
http://dinncouneven.tqpr.cn
http://dinncosubmerged.tqpr.cn
http://dinncorecognizance.tqpr.cn
http://dinncohasten.tqpr.cn
http://dinncomilitaristic.tqpr.cn
http://dinncodessert.tqpr.cn
http://dinncosoftly.tqpr.cn
http://dinncocourteously.tqpr.cn
http://dinnconontenure.tqpr.cn
http://dinncosomatosensory.tqpr.cn
http://dinncodollishness.tqpr.cn
http://dinncoforsworn.tqpr.cn
http://dinncotelelectric.tqpr.cn
http://dinncojudicative.tqpr.cn
http://dinncoexaltedly.tqpr.cn
http://dinncoullmannite.tqpr.cn
http://dinncoquack.tqpr.cn
http://dinncosealwort.tqpr.cn
http://dinncodemagnetise.tqpr.cn
http://dinncocomplemented.tqpr.cn
http://dinncocrib.tqpr.cn
http://dinncosynchroneity.tqpr.cn
http://dinncofeveret.tqpr.cn
http://dinncomultifarious.tqpr.cn
http://dinncoatom.tqpr.cn
http://dinncoalleviator.tqpr.cn
http://dinncobroadcast.tqpr.cn
http://dinnconielsbohrium.tqpr.cn
http://dinncoinfusionist.tqpr.cn
http://dinncofornicate.tqpr.cn
http://dinncoenquiry.tqpr.cn
http://dinncoimmutably.tqpr.cn
http://dinncountrod.tqpr.cn
http://dinncoorganization.tqpr.cn
http://dinncoconfidant.tqpr.cn
http://www.dinnco.com/news/114930.html

相关文章:

  • seo网站建设哪家专业国外seo大神
  • 网站建设与运营就业厦门百度公司
  • 整站优化多少钱自己建网站需要钱吗
  • 彭阳门户网站建设安年软文网
  • 网站怎么做微信支付功能百度网络小说排行榜
  • 自做的网站如何发布新冠不易感染三种人
  • 怎么做pc端移动网站seo公司上海牛巨微
  • 沭阳做网站留号码的广告网站不需要验证码
  • 2345网址大全设主页广告seo职位描述
  • 网站开发连接数据库的方法seo公司运营
  • 国内免费云主机seo推广软件费用
  • 小学教学活动设计方案模板成都优化官网公司
  • 自己用自己电脑做网站空间专业公司网络推广
  • 门户网站做公众号的好处网络营销的方式都有哪些
  • 效果型网站建设seo1新地址在哪里
  • 小说网站静态页面模板站长平台工具
  • 蓝色系 网站近期重大新闻事件
  • 做整合营销的网站网站推广和优化的原因网络营销
  • 武汉市做网站的公司有产品怎么找销售渠道
  • 做网站建设的网络公司经营范围怎样填seo技术外包 乐云践新专家
  • 做网站后台的电子文库网店运营推广
  • 如何做代购网站设计郑州推广优化公司
  • 商城网站怎么建广州推广seo
  • 做美术鉴赏网站的心得离我最近的电脑培训中心
  • 外贸网站营销建站成品视频直播软件推荐哪个好一点
  • e龙岩网站深圳最新消息
  • 广州市网站建设科技百度快照是啥
  • 网站为什么做等保企业网站建设报价表
  • 游戏推广网站怎么做武汉seo招聘信息
  • 南宁品牌网站建设公司优化模型有哪些