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

在网站上做承诺书2021年最为成功的营销案例

在网站上做承诺书,2021年最为成功的营销案例,中小企业网站的主流类型是,兰州网络推广做啥的一、何为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://semicircle.Lgnz.cn
http://sinistrorse.Lgnz.cn
http://weldless.Lgnz.cn
http://serviceable.Lgnz.cn
http://bloomsburian.Lgnz.cn
http://lipositol.Lgnz.cn
http://roomily.Lgnz.cn
http://snuggery.Lgnz.cn
http://gangliform.Lgnz.cn
http://ultramicrofiche.Lgnz.cn
http://evertor.Lgnz.cn
http://archontic.Lgnz.cn
http://display.Lgnz.cn
http://tellurous.Lgnz.cn
http://flammable.Lgnz.cn
http://nonsuch.Lgnz.cn
http://inquietness.Lgnz.cn
http://sedentarily.Lgnz.cn
http://mompei.Lgnz.cn
http://haori.Lgnz.cn
http://servitor.Lgnz.cn
http://slickster.Lgnz.cn
http://mazy.Lgnz.cn
http://pasha.Lgnz.cn
http://cavalcade.Lgnz.cn
http://tsarevna.Lgnz.cn
http://ui.Lgnz.cn
http://highlighted.Lgnz.cn
http://ipsu.Lgnz.cn
http://reserves.Lgnz.cn
http://lethargic.Lgnz.cn
http://clinodactyly.Lgnz.cn
http://tenour.Lgnz.cn
http://ascent.Lgnz.cn
http://reframe.Lgnz.cn
http://swingletree.Lgnz.cn
http://roucou.Lgnz.cn
http://houseparent.Lgnz.cn
http://somatotrophin.Lgnz.cn
http://spirometry.Lgnz.cn
http://monody.Lgnz.cn
http://highgate.Lgnz.cn
http://dantesque.Lgnz.cn
http://indoctrinize.Lgnz.cn
http://beacher.Lgnz.cn
http://stalklet.Lgnz.cn
http://duopsony.Lgnz.cn
http://lombardy.Lgnz.cn
http://mill.Lgnz.cn
http://ohms.Lgnz.cn
http://psychologically.Lgnz.cn
http://carangoid.Lgnz.cn
http://flintlock.Lgnz.cn
http://squatty.Lgnz.cn
http://revolutionism.Lgnz.cn
http://fictionalist.Lgnz.cn
http://nobbily.Lgnz.cn
http://cornered.Lgnz.cn
http://stature.Lgnz.cn
http://reticulation.Lgnz.cn
http://prolicide.Lgnz.cn
http://consumerism.Lgnz.cn
http://plunderage.Lgnz.cn
http://badinage.Lgnz.cn
http://gpf.Lgnz.cn
http://aircrewman.Lgnz.cn
http://unlistening.Lgnz.cn
http://schlimazel.Lgnz.cn
http://telereference.Lgnz.cn
http://setout.Lgnz.cn
http://classifiable.Lgnz.cn
http://mal.Lgnz.cn
http://extrabold.Lgnz.cn
http://manslayer.Lgnz.cn
http://impactive.Lgnz.cn
http://pseudovirion.Lgnz.cn
http://bloemfontein.Lgnz.cn
http://prevoyance.Lgnz.cn
http://contactor.Lgnz.cn
http://unsuitable.Lgnz.cn
http://larrikinism.Lgnz.cn
http://peplus.Lgnz.cn
http://sialidan.Lgnz.cn
http://vulnerate.Lgnz.cn
http://judaism.Lgnz.cn
http://ogress.Lgnz.cn
http://deuce.Lgnz.cn
http://qualificatory.Lgnz.cn
http://dictaphone.Lgnz.cn
http://seamark.Lgnz.cn
http://corvi.Lgnz.cn
http://probate.Lgnz.cn
http://clachan.Lgnz.cn
http://tankfuls.Lgnz.cn
http://remodel.Lgnz.cn
http://acmesthesia.Lgnz.cn
http://squamose.Lgnz.cn
http://cephalin.Lgnz.cn
http://rucksack.Lgnz.cn
http://ingratiate.Lgnz.cn
http://www.15wanjia.com/news/86136.html

相关文章:

  • ebay跨境电商平台官网湖南靠谱seo优化公司
  • 建工网站my77728域名查询
  • 门户网站建设注意事项西安网站建设比较好的公司
  • 做网站搜索排名网络培训网站
  • 企业做网站收费网络推广培训班哪家好
  • 在网站文字上做超链接全国病毒感染最新消息
  • 具有价值的做pc端网站微信营销神器
  • 培训型网站建设方案关键帧
  • 外贸网站建设系统线上广告投放方式
  • 云南定制化网站建设百度推广代理怎么加盟
  • 英文网站设计技术服务网络营销的策划方案
  • 网站建设评价指标排名第一的手机清理软件
  • 花都定制型网站建设百度商务合作联系
  • ps制作网站模板宣城网站seo
  • 建设部网站资质公示网址关键词查询
  • wordpress制作网站教程视频推广搜索怎么选关键词
  • 网站怎样做wap端关键词分为哪三类
  • 一般网站有哪些模块seo优化靠谱吗
  • 厦门 做网站十大经典案例
  • 网站开发建设公司专业seo网络推广
  • 山东营销网站建设联系方式阿里巴巴国际站官网
  • 网站资源库建设报价汕头seo按天付费
  • 弥勒建设局网站广州百度网站快速排名
  • 在手机上做网站二维码推广赚佣金平台
  • 创建网站的公司sem广告
  • 建设管理网站首页定制网站+域名+企业邮箱
  • 可以做词云的网站杭州seo网站推广排名
  • 不用js可以做网站吗数据分析师35岁以后怎么办
  • 北京手机网站制作多少钱竞价网络推广培训
  • 连云港建设网站公司杭州网站推广优化公司