|
@@ -8,8 +8,12 @@ import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import java.io.BufferedInputStream;
|
|
import java.io.File;
|
|
import java.io.File;
|
|
|
|
+import java.io.FileOutputStream;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
+import java.net.HttpURLConnection;
|
|
|
|
+import java.net.URL;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
@@ -51,12 +55,15 @@ public class FileInstallUtils {
|
|
createNamefile.mkdirs();
|
|
createNamefile.mkdirs();
|
|
}
|
|
}
|
|
try {
|
|
try {
|
|
- obsService.download(createNamefile.getPath(), photo.substring(photo.lastIndexOf("/")+1));
|
|
|
|
|
|
+// obsService.download(createNamefile.getPath(), photo.substring(photo.lastIndexOf("/")+1));
|
|
|
|
+ downloadFile(createNamefile.getPath(), photo);
|
|
System.out.println(photo.substring(photo.lastIndexOf("/")+1));
|
|
System.out.println(photo.substring(photo.lastIndexOf("/")+1));
|
|
System.out.println(photo);
|
|
System.out.println(photo);
|
|
System.out.println(createNamefile.getPath());
|
|
System.out.println(createNamefile.getPath());
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw new RuntimeException(e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -69,4 +76,22 @@ public class FileInstallUtils {
|
|
return filePath+"/"+zipFileBoList.get(0).getName();
|
|
return filePath+"/"+zipFileBoList.get(0).getName();
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+ public void downloadFile(String savedir,String fileUrl) throws Exception{
|
|
|
|
+ URL url = new URL(fileUrl);
|
|
|
|
+ HttpURLConnection conn = (HttpURLConnection)url.openConnection();
|
|
|
|
+ conn.connect();
|
|
|
|
+ BufferedInputStream br = new BufferedInputStream(conn.getInputStream());
|
|
|
|
+ File f = new File(savedir);
|
|
|
|
+ if(!f.exists()){ f.mkdirs(); }
|
|
|
|
+ FileOutputStream fos = new FileOutputStream(savedir + fileUrl.substring(fileUrl.lastIndexOf("/")));
|
|
|
|
+ byte[] buf = new byte[1024];
|
|
|
|
+ int size = 0 ;
|
|
|
|
+ while((size = br.read(buf) )!= -1){
|
|
|
|
+ fos.write(buf,0,size);
|
|
|
|
+ }
|
|
|
|
+ br.close();
|
|
|
|
+ fos.close();
|
|
|
|
+ conn.disconnect();
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|