七牛 視頻上傳 java.net.SocketTimeoutException: timeout??
新手學習做七牛云上傳視頻的時候 報錯如下,麻煩哪位大神抽空幫我檢查下、感激不盡:
java.net.SocketTimeoutException: timeout
...
...
...
Caused by: java.net.SocketException: Socket closed
我的代碼:
/**
* 視頻上傳* @param filePath* @return*/ public Map uploadMp4(String filePath){ //密鑰配置 Auth auth = Auth.create(ACCESS_KEY, SECRET_KEY); //mp4重命名 String key = new QNiuTools().getKeyByName("mp4")+".mp4"; System.out.println("key:"+key);//上傳憑證 String upTaken = auth.uploadToken(SCOPE1,key,3600,null,true); System.out.println("upTaken:"+upTaken);try { //創建上傳對象 UploadManager uploadManager = new UploadManager();Map map = new HashMap();//OkHttpClient client = new OkHttpClient(); //client.setConnectTimeout(5, TimeUnit.MINUTES); //client.setReadTimeout(5,TimeUnit.MINUTES); //client.setWriteTimeout(5,TimeUnit.MINUTES);//調用put方法上傳 Response res = uploadManager.put(filePath, key, upTaken); //uploadManager.put(new File(filePath),key,upTaken); String fileName = key.substring(key.lastIndexOf("/")+1,key.length()) ; map.put("fileName",fileName); map.put("info","http://"+SCOPE_DOMAIN1+"/"); map.put("path",key.substring(0,key.lastIndexOf("/")+1)); System.out.println(map.get("in<愛尬聊_百科全書>fo")+""+key); System.out.println("==================="); return map; } catch (QiniuException e) { e.printStackTrace(); } return null; }
