去草料网
制作下需要扫码下载的 二维码图片
加上自己的连接
上传logo
将生成的二维码用PS稍微美化下
加上想要的文字 一般图片大小 1000x1300
签名打包ionic3项目
参考地址
后台服务器项目书写是下载的代码
将app的包放在资源目录下
代码
package com.bjtcrj.gms.resource.controller; import org.apache.commons.io.IOUtils; import org.springframework.core.io.ResourceLoader; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import javax.annotation.Resource; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; @Controller @RequestMapping({ "/app" }) public class UploadAppController { @Resource private ResourceLoader resourceLoader; @RequestMapping(value = "/downapp",method = RequestMethod.GET) public void downloadFile(HttpServletRequest request, HttpServletResponse response, String type) throws IOException { String fileName = "wanggeApp.apk"; String showName = "智慧网格.apk"; if ("ios".equalsIgnoreCase(type)) { fileName = "wanggeApp.ipa"; showName = "智慧网格.ipa"; } if (fileName != null) { InputStream inputStream = null; ServletOutputStream servletOutputStream = null; String encodeName = URLEncoder.encode(showName, StandardCharsets.UTF_8.toString()); try { String filePath = File.separator + "appload" + File.separator + fileName; org.springframework.core.io.Resource resource = resourceLoader.getResource("classpath:" + filePath); response.setContentType("application/force-download"); response.addHeader("Cache-Control", "no-cache, no-store, must-revalidate"); response.addHeader("charset", "utf-8"); response.addHeader("Pragma", "no-cache"); response.setHeader("Content-Disposition", "attachment; filename*=utf-8''" + encodeName); // response.setHeader("Content-Disposition", "attachment; filename=\"" + encodeName + "\"; filename*=utf-8''" + encodeName); inputStream = resource.getInputStream(); servletOutputStream = response.getOutputStream(); IOUtils.copy(inputStream, servletOutputStream); response.flushBuffer(); } catch (Exception e) { System.out.println("应用已暂停下载! ---------------- "+fileName); response.setHeader("Content-Disposition", "attachment; filename*=utf-8''" + encodeName); response.flushBuffer(); // String data = "应用已暂停下载!"; // OutputStream outputStream = response.getOutputStream(); // response.setHeader("content-type", "text/html;charset=UTF-8"); // byte[] dataByteArr = data.getBytes("UTF-8"); // outputStream.write(dataByteArr); } finally { try { if (inputStream != null) { inputStream.close(); inputStream = null; } if (servletOutputStream != null) { try { servletOutputStream.close(); }catch (Exception e){ } servletOutputStream = null; } // 召唤jvm的垃圾回收器 System.gc(); } catch (Exception e) { e.printStackTrace(); } } } } }
将后台项目部署到二维码网址的服务器路径
最后是测试,打开你的那个二维码图片测试吧