tianboguang преди 3 години
родител
ревизия
40a1c17dc5

+ 0 - 3
4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/ConstantUrl.java

@@ -8,7 +8,6 @@ public class ConstantUrl {
 //	public static final String DEFAULT_USER_HEAD = "https://scene3d.4dage.com/head.png";
     public static final String DEFAULT_USER_HEAD = "https://4dkk.4dage.com/newHead.png";
     public static final String BBS_TOUPLOAD = "https://scene3d.4dage.com/model/upload/image/";
-    public static final String DEFAULT_PREFIX_QINIU_PIC = "http://orw69myb5.bkt.clouddn.com/";
     public static final String DEFAULT_SCENE_PIC="https://4dkk.4dage.com/loading/thumb.jpg";
 //	public static final String SCENE_URL = MAIN_URL + "show.html?m=";
 //	public static final String SCENE_URL2 = MAIN_URL + "showV2.html?m=";
@@ -17,8 +16,6 @@ public class ConstantUrl {
     public static final String PREFIX_ALI = "https://4dkk.4dage.com/";
     //亚马逊S3
     public static final String PREFIX_AWS = "https://testeurs3.4dkankan.com/";
-    public static final String PREFIX_QINIU = "https://scene3d.4dage.com/";
-    public static final String PREFIX_QINIU2 = "https://creator.4dkankan.com/";
     public static final String WEIXIN_PAYURL = "https://www.4dkankan.com/weixinmobilepay/weixinInfo?orderId=";
     public static final String WEIXIN_TOKEN_URL1 = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=";
     public static final String WEIXIN_TOKEN_URL2 = "https://api.weixin.qq.com/sns/userinfo?access_token=";

+ 17 - 7
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/FileUtils.java

@@ -36,20 +36,30 @@ public class FileUtils {
     //文件路径+名称
     private static String fileNameTemp;
 
-    public static void uploadImg(String path, String base64Data)
-            throws Exception {
+    public static byte[] getImageByte(String base64Data){
         byte[] bt = null;
         try {
-            BASE64Decoder decoder = new BASE64Decoder();
+            sun.misc.BASE64Decoder decoder = new sun.misc.BASE64Decoder();
             if (base64Data.startsWith("data:image/png;base64,")) {
-                bt = decoder.decodeBuffer(base64Data.replace("data:image/png;base64,", ""));
+                return decoder.decodeBuffer(base64Data.replace("data:image/png;base64,", ""));
             } else if (base64Data.startsWith("data:image/jpeg;base64,")) {
-                bt = decoder.decodeBuffer(base64Data.replace("data:image/jpeg;base64,", ""));
+                return decoder.decodeBuffer(base64Data.replace("data:image/jpeg;base64,", ""));
             } else if (base64Data.startsWith("data:image/bmp;base64,")) {
-                bt = decoder.decodeBuffer(base64Data.replace("data:image/bmp;base64,", ""));
+                return decoder.decodeBuffer(base64Data.replace("data:image/bmp;base64,", ""));
             } else {
-                return;
+                return bt;
             }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return bt;
+    }
+
+    public static void uploadImg(String path, String base64Data)
+            throws Exception {
+
+        try {
+            byte[] bt = getImageByte(base64Data);
             writeBinary(bt, path);
         } catch (IOException e) {
             e.printStackTrace();

+ 0 - 19
4dkankan-utils-fyun/pom.xml

@@ -53,25 +53,6 @@
             <version>1.11.327</version>
         </dependency>
 
-
-        <dependency>
-            <groupId>com.qiniu</groupId>
-            <artifactId>qiniu-java-sdk</artifactId>
-            <version>7.2.0</version>
-        </dependency>
-
-        <dependency>
-            <groupId>com.qiniu</groupId>
-            <artifactId>qiniu-java-sdk</artifactId>
-            <version>[7.2.0,7.2.99]</version>
-        </dependency>
-        <dependency>
-            <groupId>com.qiniu</groupId>
-            <artifactId>happy-dns-java</artifactId>
-            <version>0.1.4</version>
-            <scope>compile</scope>
-        </dependency>
-
         <dependency>
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-lang3</artifactId>

+ 0 - 9
4dkankan-utils-fyun/src/main/java/com/fdkankan/fyun/oss/UploadToOssUtil.java

@@ -26,11 +26,7 @@ import com.amazonaws.services.s3.model.S3ObjectInputStream;
 import com.amazonaws.services.s3.model.S3ObjectSummary;
 import com.fdkankan.common.util.CreateObjUtil;
 import com.fdkankan.fyun.constant.StorageType;
-import com.qiniu.common.Zone;
-import com.qiniu.storage.Configuration;
-import com.qiniu.storage.UploadManager;
 import java.net.URLDecoder;
-import java.util.function.Consumer;
 import java.util.stream.Collectors;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.fileupload.FileItem;
@@ -56,11 +52,6 @@ import java.util.Map;
 @Component
 public class UploadToOssUtil {
 
-	Zone zone = Zone.autoZone();
-
-	Configuration config = new Configuration(zone);
-	UploadManager uploadManager = new UploadManager(config);
-
 	@Value("${oss.point:http://oss-cn-shenzhen-internal.aliyuncs.com}")
 	private String point;
 

+ 0 - 169
4dkankan-utils-fyun/src/main/java/com/fdkankan/fyun/qiniu/QiniuUpload.java

@@ -1,169 +0,0 @@
-package com.fdkankan.fyun.qiniu;
-
-import com.google.gson.Gson;
-import com.qiniu.cdn.CdnManager;
-import com.qiniu.cdn.CdnResult;
-import com.qiniu.common.QiniuException;
-import com.qiniu.http.Response;
-import com.qiniu.storage.BucketManager;
-import com.qiniu.storage.Configuration;
-import com.qiniu.storage.UploadManager;
-import com.qiniu.storage.model.DefaultPutRet;
-import com.qiniu.util.Auth;
-import com.qiniu.util.StringMap;
-import com.qiniu.util.UrlSafeBase64;
-
-import java.io.File;
-
-public class QiniuUpload {
-
-	//删除文件
-	public static void delete(String key) throws QiniuException{
-		Configuration cfg = new Configuration(QiniuUtil.zone);
-		Auth auth = Auth.create(QiniuUtil.accessKey, QiniuUtil.secretKey);
-		BucketManager bucketManager = new BucketManager(auth, cfg);
-        bucketManager.delete(QiniuUtil.bucket, key);
-	}
-
-	//刷新文件
-	public static void refresh(String url) throws QiniuException{
-		String [] urls = {url};
-		Auth auth = Auth.create(QiniuUtil.accessKey, QiniuUtil.secretKey);
-		CdnManager c = new CdnManager(auth);
-		CdnResult.RefreshResult response = c.refreshUrls(urls);
-	}
-
-
-	/**
-	 * 上传单个文件到七牛云
-	 * @param key
-	 * @param localFilePath
-	 */
-	public static boolean setFileToBucket(String key, String localFilePath){
-		Configuration cfg = new Configuration(QiniuUtil.zone);
-		Auth auth = Auth.create(QiniuUtil.accessKey, QiniuUtil.secretKey);
-		UploadManager uploadManager = new UploadManager(cfg);
-		
-		String upToken = auth.uploadToken(QiniuUtil.bucket);
-		
-		try {
-		    Response response = uploadManager.put(localFilePath, key, upToken);
-		    //解析上传成功的结果
-		    DefaultPutRet putRet = new Gson().fromJson(response.bodyString(), DefaultPutRet.class);
-		    System.out.println(putRet.key);
-		    System.out.println(putRet.hash);
-		    return true;
-		} catch (QiniuException ex) {
-		    Response r = ex.response;
-		    System.err.println(r.toString());
-		    try {
-		        System.err.println(r.bodyString());
-		    } catch (QiniuException ex2) {
-		    }
-		    return false;
-		}
-	}
-	
-	/**
-	 * 上传本地目录下所有文件到七牛云上
-	 * @param remoteFolder
-	 * @param localFolderPath
-	 */
-	public static void setFilesToBucket(String remoteFolder, String localFolderPath) {
-		Configuration cfg = new Configuration(QiniuUtil.zone);
-		Auth auth = Auth.create(QiniuUtil.accessKey, QiniuUtil.secretKey);
-		UploadManager uploadManager = new UploadManager(cfg);
-		
-		File file = new File(localFolderPath);
-		File[] files = file.listFiles();// 获取目录下的所有文件或文件夹
-		if (files == null) {// 如果目录为空,直接退出
-			return;
-		}
-
-		// 遍历,目录下的所有文件
-		for (File f : files) {
-			if (f.isFile()) {
-				String key = f.getName();
-				if (remoteFolder != null) {
-					key = remoteFolder + key;
-				} 
-				// 再上传文件
-				String upToken = auth.uploadToken(QiniuUtil.bucket);
-				try {
-					Response res = uploadManager.put(f, key, upToken);
-					System.out.println(res.bodyString());
-				} catch (QiniuException e) {
-					Response r = e.response;
-					System.err.println(r.toString());
-					try {
-						System.err.println(r.bodyString());
-					} catch (QiniuException ex2) {
-					}
-				}
-			} else if (f.isDirectory()) {
-				String key = f.getName() + "/";
-				if (remoteFolder != null) {
-					key = remoteFolder + key;
-				}
-				setFilesToBucket(key, f.getAbsolutePath());
-			}
-		}
-	}
-
-	/**
-	 * 测试七牛上传后,自动进行数据处理操作,并另存处理后的文件
-	 * @param domain 存储空间所对应的域名
-	 * @param file 上传文件
-	 */
-	public static void testFops(String domain, File file) {
-		//通过AK,SK创建Auth 对象
-		Auth auth = Auth.create(QiniuUtil.accessKey, QiniuUtil.secretKey);
-		Configuration cfg = new Configuration(QiniuUtil.zone);
-		//上传对象
-		UploadManager uploadMgr = new UploadManager(cfg);
-		//私有队列
-		String pipeline = "av-pipeline";
-		//水印文字
-		String wmText = UrlSafeBase64.encodeToString("Word For Test");
-		//水印文字的颜色
-		String wmFontColor = UrlSafeBase64.encodeToString("#FFFF00");
-		//设置avthumb 接口
-		StringBuffer ops = new StringBuffer("");
-		ops.append("avthumb/mp4/wmText/" + wmText +"/wmGravityText/NorthEast/wmFontColor/" + wmFontColor);
-		String saveAs = UrlSafeBase64.encodeToString(QiniuUtil.bucket + ":" + "new_" + file.getName());
-		//通过管道符 "|" 拼接 saveas 接口, 保存 数据处理后的视频
-		ops.append("|saveas/" + saveAs);
-		//saveas 接口 需要签名 sign
-		String sign = domain + "/" + file.getName() + "?" + ops.toString();
-		String encodeSign = UrlSafeBase64.encodeToString(sign);
-		ops.append("/sign/" + encodeSign);
-		//指定 数据处理 的 上传策略, 当文件上传成功后,自定执行数据处理操作,即:ops 的接口,图片加水印,另存为 new_file.getName();
-		StringMap putPolicy = new StringMap();
-		putPolicy.put("persistentOps", ops.toString())      //数据处理接口及参数
-				.put("persistentPipeline", pipeline);      //私有数据处理队列
-
-		//获取上传凭证, 包含上传策略
-		String uploadToken = auth.uploadToken(QiniuUtil.bucket, file.getName(), 3600, putPolicy);
-
-		try {
-			//上传
-			Response resp = uploadMgr.put(file, file.getName(), uploadToken);
-			//查看结果
-			System.out.println(resp.statusCode + ":" + resp.bodyString());
-		} catch (QiniuException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
-
-	}
-
-    public static void main(String[] args) {
-        QiniuUpload upload = new QiniuUpload();
-        try {
-            QiniuUpload.delete("head/13211064273/head.png");
-//            QiniuUpload.refresh("http://scene3d.4dage.com/head/13211064273/head.png");
-        } catch (QiniuException e) {
-            e.printStackTrace();
-        }
-    }
-}

+ 0 - 238
4dkankan-utils-fyun/src/main/java/com/fdkankan/fyun/qiniu/QiniuUtil.java

@@ -1,238 +0,0 @@
-package com.fdkankan.fyun.qiniu;
-
-import com.qiniu.common.Zone;
-import com.qiniu.util.Auth;
-import com.qiniu.util.UrlSafeBase64;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.util.EntityUtils;
-
-import java.io.IOException;
-import java.net.URLEncoder;
-
-public class QiniuUtil {
-
-    public static String accessKey = "dlPPwgZky_F-iP8CbSbJpiAtAcqw3BYwb9rdHMrS";
-    public static String secretKey = "YEtkLKDsImXB-8m1CT1zV_YwCwwGvrUvo2ktj9KZ";
-    public static Zone zone = Zone.zone1();
-    public static String bucket = "scene3d";
-    public static String remoteUrl = "https://4dkanzhan.4dkankan.com/";
-
-    /**
-     * 视频帧缩略图接口(vframe)用于从视频流中截取指定时刻的单帧画面并按指定大小缩放成图片
-     * @param key 文件名  a.mp4
-     * @param suffixName 输出的目标截图格式,支持jpg、png等。
-     * @param second 指定截取视频的时刻,单位:秒,精确到毫秒。
-     * @param width 缩略图宽度,单位:像素(px),取值范围为1-3840, 可不传。
-     * @param height 缩略图高度,单位:像素(px),取值范围为1-2160, 可不传。
-     * @param rotate 指定顺时针旋转的度数,可取值为90、180、270、auto,默认为不旋转,可不传。
-     * @param newKey 新文件名称
-     * @param notifyURL 回调地址
-     * @throws IOException
-     */
-    public static void getVideoFrame(String key, String suffixName, String second, Integer width, Integer height, Integer rotate, String newKey, String notifyURL) throws IOException {
-        StringBuffer sb = new StringBuffer("vframe/").append(suffixName).append("/offset/").append(second);
-        if (width != null){
-            sb.append("/w/").append(width);
-        }
-        if (height != null){
-            sb.append("/h/").append(height);
-        }
-        if (rotate != null){
-            sb.append("/rotate/").append(rotate);
-        }
-
-        String fop = URLEncoder.encode(sb.toString(), "utf-8");
-        StringBuffer ops = new StringBuffer("bucket=").append(bucket).append("&key=").append(key).append("&fops=").append(fop);
-        String saveAs = UrlSafeBase64.encodeToString(bucket + ":" + newKey);
-        ops.append("|saveas/").append(saveAs);
-
-        ops.append("&notifyURL=").append(notifyURL);
-
-        HttpPost post = new HttpPost("http://api.qiniu.com/pfop/");
-        post.setHeader(HTTP.CONTENT_TYPE, "application/x-www-form-urlencoded");
-        StringEntity entity = new StringEntity(ops.toString(), "utf-8");
-        entity.setContentType("application/x-www-form-urlencoded");
-        post.setEntity(entity);
-
-        Auth auth = Auth.create(accessKey, secretKey);
-        String si = auth.signRequest("http://api.qiniu.com/pfop/", ops.toString().getBytes(), "application/x-www-form-urlencoded");
-        post.setHeader("Authorization", "QBox " + si);
-        HttpClient client = new DefaultHttpClient();
-        HttpResponse res = client.execute(post);
-        String ret = EntityUtils.toString(res.getEntity(), "UTF-8");
-        System.out.println(ret);
-
-    }
-
-    /**
-     * 给视频添加水印
-     * @param key a.mp4
-     * @param text  4dage
-     * @param fontColor #FFFF00
-     * @param newKey new_a.mp4
-     * @param notifyURL 回调地址
-     * @throws IOException
-     */
-    public static void waterMark(String key, String text, String fontColor, String newKey, String notifyURL) throws IOException {
-        String fop = "avthumb/mp4/";
-        fop = URLEncoder.encode(fop, "utf-8");
-        //水印文字
-        String wmText = UrlSafeBase64.encodeToString(text);
-        //水印文字的颜色
-        String wmFontColor = UrlSafeBase64.encodeToString(fontColor);
-        //设置avthumb 接口
-        StringBuffer ops = new StringBuffer("bucket=").append(bucket).append("&key=").append(key).append("&fops=").append(fop);
-        ops.append("avthumb/mp4/wmText/").append(wmText).append("/wmGravityText/NorthEast/wmFontColor/").append(wmFontColor);
-        String saveAs = UrlSafeBase64.encodeToString(bucket + ":" + newKey);
-        ops.append("|saveas/").append(saveAs);
-        ops.append("&notifyURL=").append(notifyURL);
-
-        HttpPost post = new HttpPost("http://api.qiniu.com/pfop/");
-        post.setHeader(HTTP.CONTENT_TYPE, "application/x-www-form-urlencoded");
-        StringEntity entity = new StringEntity(ops.toString(), "utf-8");
-        entity.setContentType("application/x-www-form-urlencoded");
-        post.setEntity(entity);
-
-        Auth auth = Auth.create(accessKey, secretKey);
-        String si = auth.signRequest("http://api.qiniu.com/pfop/", ops.toString().getBytes(), "application/x-www-form-urlencoded");
-        post.setHeader("Authorization", "QBox " + si);
-        HttpClient client = new DefaultHttpClient();
-        HttpResponse res = client.execute(post);
-        String ret = EntityUtils.toString(res.getEntity(), "UTF-8");
-        System.out.println(ret);
-    }
-
-    /**
-     * 将4K图片裁剪成64张512*512
-     * @param key
-     * @param notifyURL  回调地址 "http://wwww.cn/qn/notify&force=1"
-     * @throws IOException
-     */
-    public static void crop4K(String key, String notifyURL) throws IOException {
-        String fop = "imageMogr2/auto-orient/";
-        fop = URLEncoder.encode(fop, "utf-8");
-
-        String fileName = key.substring(0, key.lastIndexOf("."));
-        String suffixName = key.substring(key.lastIndexOf("."));
-
-        Auth auth = Auth.create(accessKey, secretKey);
-
-        for (int i = 0; i < 8; i++) {
-            for (int j = 0; j < 8; j++) {
-                String ret = crop(key, notifyURL, fop, fileName, suffixName, auth, i, j);
-                System.out.println(ret);
-            }
-        }
-    }
-
-    /**
-     * 将2K图片裁剪成16张512*512
-     * @param key
-     * @param notifyURL 回调地址 "http://wwww.cn/qn/notify&force=1"
-     * @throws IOException
-     */
-    public static void crop2k(String key, String notifyURL) throws IOException {
-        String fop = "imageMogr2/auto-orient/";
-        fop = URLEncoder.encode(fop, "utf-8");
-
-        String fileName = key.substring(0, key.lastIndexOf("."));
-        String suffixName = key.substring(key.lastIndexOf("."));
-
-        Auth auth = Auth.create(accessKey, secretKey);
-
-        for (int i = 0; i < 4; i++) {
-            for (int j = 0; j < 4; j++) {
-                String ret = crop(key, notifyURL, fop, fileName, suffixName, auth, i, j);
-                System.out.println(ret);
-            }
-        }
-    }
-
-    /**
-     * 将1K图片裁剪成4张512*512
-     * @param key
-     * @param notifyURL 回调地址 "http://wwww.cn/qn/notify&force=1"
-     * @throws IOException
-     */
-    public static void crop1k(String key, String notifyURL) throws IOException {
-        String fop = "imageMogr2/auto-orient/";
-        fop = URLEncoder.encode(fop, "utf-8");
-
-        String fileName = key.substring(0, key.lastIndexOf("."));
-        String suffixName = key.substring(key.lastIndexOf("."));
-
-        Auth auth = Auth.create(accessKey, secretKey);
-
-        for (int i = 0; i < 2; i++) {
-            for (int j = 0; j < 2; j++) {
-                String ret = crop(key, notifyURL, fop, fileName, suffixName, auth, i, j);
-                System.out.println(ret);
-            }
-        }
-    }
-
-    private static String crop(String key, String notifyURL, String fop, String fileName, String suffixName, Auth auth, int i, int j) throws IOException {
-        StringBuffer ops = new StringBuffer("bucket=").append(bucket).append("&key=").append(key).append("&fops=").append(fop);
-        ops.append("crop/!512x512a" + j * 512 + "a" + i * 512);
-
-        String saveAs = UrlSafeBase64.encodeToString(bucket + ":" + fileName + "_" + j + "_" + i + suffixName);
-        ops.append("|saveas/").append(saveAs);
-        ops.append("&notifyURL=").append(notifyURL);
-        HttpPost post = new HttpPost("http://api.qiniu.com/pfop/");
-        post.setHeader(HTTP.CONTENT_TYPE, "application/x-www-form-urlencoded");
-        StringEntity entity = new StringEntity(ops.toString(), "utf-8");
-        entity.setContentType("application/x-www-form-urlencoded");
-        post.setEntity(entity);
-
-        String si = auth.signRequest("http://api.qiniu.com/pfop/", ops.toString().getBytes(), "application/x-www-form-urlencoded");
-        post.setHeader("Authorization", "QBox " + si);
-        HttpClient client = new DefaultHttpClient();
-        HttpResponse res = client.execute(post);
-        return EntityUtils.toString(res.getEntity(), "UTF-8");
-    }
-
-    /**
-     * 将七牛云上的图片缩放成指定大小的图片
-     * @param key
-     * @param width
-     * @param height
-     * @param notifyURL
-     * @throws IOException
-     */
-    public static void thumb(String key, String width, String height, String notifyURL, String newKey) throws IOException {
-        String fop = "imageMogr2/auto-orient/";
-        fop = URLEncoder.encode(fop, "utf-8");
-
-        String fileName = key.substring(0, key.lastIndexOf("."));
-        String suffixName = key.substring(key.lastIndexOf("."));
-
-        Auth auth = Auth.create(accessKey, secretKey);
-
-        StringBuffer ops = new StringBuffer("bucket=").append(bucket).append("&key=").append(key).append("&fops=").append(fop);
-        ops.append("thumbnail/"+width+"x"+height+"!");
-
-        //saveAs新生成文件的名称
-        newKey = StringUtils.isNotEmpty(newKey) ? newKey : (fileName + "_thumb" + suffixName);
-        String saveAs = UrlSafeBase64.encodeToString(bucket + ":" + newKey);
-        ops.append("|saveas/").append(saveAs);
-        ops.append("&notifyURL=").append(notifyURL);
-        HttpPost post = new HttpPost("http://api.qiniu.com/pfop/");
-        post.setHeader(HTTP.CONTENT_TYPE, "application/x-www-form-urlencoded");
-        StringEntity entity = new StringEntity(ops.toString(), "utf-8");
-        entity.setContentType("application/x-www-form-urlencoded");
-        post.setEntity(entity);
-
-        String si = auth.signRequest("http://api.qiniu.com/pfop/", ops.toString().getBytes(), "application/x-www-form-urlencoded");
-        post.setHeader("Authorization", "QBox " + si);
-        HttpClient client = new DefaultHttpClient();
-        HttpResponse res = client.execute(post);
-        System.out.println(EntityUtils.toString(res.getEntity(), "UTF-8"));
-    }
-
-}