| | |
| | | } |
| | | |
| | | |
| | | /**生成无限二维码,并上传到OSS*/ |
| | | public static String createUnlimitQrCode(String at, String scene, String page, int width, boolean autoColor, |
| | | JSONObject lineColor, boolean isHyaline, String fileName, String keyId, |
| | | String keySecret, String endPoint, String bucket, String env_version) |
| | | { |
| | | |
| | | /**生成无限二维码,返回临时文 |
| | | * @param at 微信token |
| | | * @param scene 参数,只能32位,最好不要中文 |
| | | * @param page 跳转链接 |
| | | * @param width 宽度 |
| | | * @param autoColor 默认false |
| | | * @param lineColor 默认null |
| | | * @param isHyaline 默认false |
| | | * @return |
| | | */ |
| | | public static File createUnlimitQrCode(String at, String scene, String page, int width, boolean autoColor, |
| | | JSONObject lineColor, boolean isHyaline, String env_version) throws IOException { |
| | | String imgUrl = null; |
| | | InputStream in = null; |
| | | HttpURLConnection conn = null; |
| | | |
| | | //创建临时文件 |
| | | File file = File.createTempFile("temp", ".jpg"); |
| | | |
| | | try { |
| | | //生成发送数据 |
| | |
| | | if (conn.getResponseCode() == 200) { |
| | | // 请求返回的数据 |
| | | in = conn.getInputStream(); |
| | | imgUrl = OSSUtil.uploadImg(fileName, in, keyId, keySecret, endPoint, bucket); |
| | | //输入到临时文件 |
| | | /*OutputStream os = new FileOutputStream(file); |
| | | int bytesRead = 0; |
| | | byte[] buffer = new byte[8192]; |
| | | while ((bytesRead = in.read(buffer, 0, 8192)) != -1) { |
| | | os.write(buffer, 0, bytesRead); |
| | | }*/ |
| | | FileUtils.copyInputStreamToFile(in, file); |
| | | |
| | | conn.disconnect(); |
| | | conn = null; |
| | | } |
| | |
| | | conn.disconnect(); |
| | | conn = null; |
| | | } |
| | | }catch (Exception e) |
| | | { |
| | | }catch (Exception e) { |
| | | e.printStackTrace(); |
| | | |
| | | if (in != null) { |
| | | try { |
| | | in.close(); |
| | | }catch (Exception ep) |
| | | { |
| | | }catch (Exception ep) { |
| | | ep.printStackTrace(); |
| | | } |
| | | in = null; |
| | |
| | | conn.disconnect(); |
| | | conn = null; |
| | | } |
| | | }finally { |
| | | file.deleteOnExit(); |
| | | } |
| | | |
| | | return imgUrl; |
| | | return file; |
| | | } |
| | | |
| | | } |