| | |
| | | String url = ossClient.generatePresignedUrl(bucketName, fileName, expiration).toString(); |
| | | System.out.println("oss上传成功:" + url); |
| | | |
| | | URL urlO = new URL(url); |
| | | HttpURLConnection conn = (HttpURLConnection) urlO.openConnection(); |
| | | conn.setRequestMethod("GET"); |
| | | conn.setConnectTimeout(10 * 1000); |
| | | conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)"); |
| | | |
| | | InputStream inputStream2 = conn.getInputStream();// 通过输入流获取图片数据 |
| | | |
| | | byte[] data = readInputStream(inputStream2); |
| | | |
| | | System.out.println("获取图片成功:" + url); |
| | | // URL urlO = new URL(url); |
| | | // HttpURLConnection conn = (HttpURLConnection) urlO.openConnection(); |
| | | // conn.setRequestMethod("GET"); |
| | | // conn.setConnectTimeout(10 * 1000); |
| | | // conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)"); |
| | | // |
| | | // InputStream inputStream2 = conn.getInputStream();// 通过输入流获取图片数据 |
| | | // |
| | | // byte[] data = readInputStream(inputStream2); |
| | | // |
| | | // System.out.println("获取图片成功:" + url); |
| | | return url; |
| | | } catch (Exception e) { |
| | | System.out.println("oss异常:" + e.getMessage()); |