| 
														
															@@ -13,7 +13,8 @@ const JSZIP = require('jszip'); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 require('dotenv').config({ path: './env/.env.test' }); 
														 | 
														
														 | 
														
															 require('dotenv').config({ path: './env/.env.test' }); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 const session = require('express-session'); 
														 | 
														
														 | 
														
															 const session = require('express-session'); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 const multer  = require('multer'); 
														 | 
														
														 | 
														
															 const multer  = require('multer'); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-const XLSX = require('xlsx');  
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+const XLSX = require('xlsx'); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+const pptxgen = require('pptxgenjs'); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 const {Document, Packer, Paragraph, TextRun} = require('docx'); 
														 | 
														
														 | 
														
															 const {Document, Packer, Paragraph, TextRun} = require('docx'); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 let WebSocketServer = require('websocket').server; 
														 | 
														
														 | 
														
															 let WebSocketServer = require('websocket').server; 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -231,9 +232,9 @@ serverApp.post("/api-post", authProvider.acquireToken({ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 })); 
														 | 
														
														 | 
														
															 })); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 serverApp.post("/getGroupList", authProvider.acquireToken({ 
														 | 
														
														 | 
														
															 serverApp.post("/getGroupList", authProvider.acquireToken({ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        scopes: ['.default'], 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        redirectUri: redirectUri, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        successRedirect: '/group-redirect' 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    scopes: ['.default'], 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    redirectUri: redirectUri, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    successRedirect: '/group-redirect' 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 })); 
														 | 
														
														 | 
														
															 })); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    
														 | 
														
														 | 
														
															    
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -244,10 +245,12 @@ serverApp.get("/group-redirect", 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     try { 
														 | 
														
														 | 
														
															     try { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         const oneDrive = await getFetch(endPoint + "/me/drive/root", req.session.accessToken); 
														 | 
														
														 | 
														
															         const oneDrive = await getFetch(endPoint + "/me/drive/root", req.session.accessToken); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         const sharePointIds = await getFetch(endPoint + "/me/drive/SharePointIds", req.session.accessToken); 
														 | 
														
														 | 
														
															         const sharePointIds = await getFetch(endPoint + "/me/drive/SharePointIds", req.session.accessToken); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        // const publicTeam = await getFetch(endPoint + "/groups?$filter=groupTypes/any(c:c+eq+'Unified')", req.session.accessToken); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         const graphResponse = await getFetch(endPoint + "/me/joinedTeams", req.session.accessToken); 
														 | 
														
														 | 
														
															         const graphResponse = await getFetch(endPoint + "/me/joinedTeams", req.session.accessToken); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         const sites = await getFetch(endPoint + "/sites/root", req.session.accessToken); 
														 | 
														
														 | 
														
															         const sites = await getFetch(endPoint + "/sites/root", req.session.accessToken); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         const sitesSharePoint = await getFetch(endPoint + "/sites/root/SharePointIds", req.session.accessToken); 
														 | 
														
														 | 
														
															         const sitesSharePoint = await getFetch(endPoint + "/sites/root/SharePointIds", req.session.accessToken); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        // const public = publicTeam.value; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         const teams = graphResponse.value; 
														 | 
														
														 | 
														
															         const teams = graphResponse.value; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         oneDrive.sharePoint = sharePointIds; 
														 | 
														
														 | 
														
															         oneDrive.sharePoint = sharePointIds; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         sites.sharePoint = sitesSharePoint; 
														 | 
														
														 | 
														
															         sites.sharePoint = sitesSharePoint; 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -257,6 +260,7 @@ serverApp.get("/group-redirect", 
														 | 
													
												
											
												
													
														| 
														 | 
														
															           }, 
														 | 
														
														 | 
														
															           }, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															           joinedTeams : { 
														 | 
														
														 | 
														
															           joinedTeams : { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             teams : teams, 
														 | 
														
														 | 
														
															             teams : teams, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            // teams : public, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             items : {}, 
														 | 
														
														 | 
														
															             items : {}, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															           }, 
														 | 
														
														 | 
														
															           }, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															           sites : { 
														 | 
														
														 | 
														
															           sites : { 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -265,15 +269,17 @@ serverApp.get("/group-redirect", 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															         if (teams && teams.length) { 
														 | 
														
														 | 
														
															         if (teams && teams.length) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-          const options = { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            responseType: 'arraybuffer', 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            headers: { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-              Authorization: `Bearer ${req.session.accessToken}`, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-              ConsistencyLevel: 'eventual', 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-              withCredentials:true, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            }, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-          }; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        // if (public && public.length) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          // const options = { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          //   responseType: 'arraybuffer', 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          //   headers: { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          //     Authorization: `Bearer ${req.session.accessToken}`, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          //     ConsistencyLevel: 'eventual', 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          //     withCredentials:true, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          //   }, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          // }; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															           for (let team of teams) { 
														 | 
														
														 | 
														
															           for (let team of teams) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          // for (let team of public) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             const item = await getFetch(endPoint + "/groups/"+team.id+"/drive/items/root/children", req.session.accessToken); 
														 | 
														
														 | 
														
															             const item = await getFetch(endPoint + "/groups/"+team.id+"/drive/items/root/children", req.session.accessToken); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             const sharePoint = await getFetch(endPoint + "/groups/"+team.id+"/drive/SharePointIds", req.session.accessToken); 
														 | 
														
														 | 
														
															             const sharePoint = await getFetch(endPoint + "/groups/"+team.id+"/drive/SharePointIds", req.session.accessToken); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             // const image = await axios.get(endPoint + "/groups/" + team.id + "/photo/$value", options); 
														 | 
														
														 | 
														
															             // const image = await axios.get(endPoint + "/groups/" + team.id + "/photo/$value", options); 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -316,34 +322,65 @@ serverApp.post('/api/makeFolder', 
														 | 
													
												
											
												
													
														| 
														 | 
														
															           Authorization: `Bearer ${req.session.accessToken}`, 
														 | 
														
														 | 
														
															           Authorization: `Bearer ${req.session.accessToken}`, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         }, 
														 | 
														
														 | 
														
															         }, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       }; 
														 | 
														
														 | 
														
															       }; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-      const {siteId, path, param} = req.body; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      const {siteId, path, name} = req.body; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      const resultObj = {message:"", success: 'F'}; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      const param ={ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        name: name, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        folder: { }, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        '@microsoft.graph.conflictBehavior': 'rename' 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       try{ 
														 | 
														
														 | 
														
															       try{ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         const sitesInfo = await axios.get(endPoint + "/sites/"+ siteId + path, options); 
														 | 
														
														 | 
														
															         const sitesInfo = await axios.get(endPoint + "/sites/"+ siteId + path, options); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        if (sitesInfo.data) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        if (sitesInfo.data && sitesInfo.data.id) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															           const itemId = sitesInfo.data.id; 
														 | 
														
														 | 
														
															           const itemId = sitesInfo.data.id; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-          const result = await axios.post(endPoint + "/sites/"+ siteId +"/drive/items/" + itemId +"/children", JSON.parse(param), options); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-          res.json(result.data) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          const result = await axios.post(endPoint + "/sites/"+ siteId +"/drive/items/" + itemId +"/children",param, options); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+           
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          if (result.data) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            resultObj.message = "폴더가 생성되었습니다.<br>폴더명 : "+ name; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            resultObj.success = 'S'; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          else { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            resultObj.message = "폴더가 생성되지 않았습니다."; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        else { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          resultObj.message = "생성할 폴더 경로를 찾을 수 없습니다."; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       } 
														 | 
														
														 | 
														
															       } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       catch(error) { 
														 | 
														
														 | 
														
															       catch(error) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        console.log(error.response.data.error);  
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-         
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        // resultObj.success = 'F'; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        // resultObj.message = '선택하신 파일 정보 삭제중 오류가 발생하였습니다.\n' + error.response.data.error.message; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        // return res.json(resultObj); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        resultObj.message = "폴더 생성 중 오류가 발생하였습니다.<br>" + getErrorMessage(error); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       } 
														 | 
														
														 | 
														
															       } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-}) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      res.json(resultObj); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+}); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+function getErrorMessage(error) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  let errorText = ""; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  if (error.response && error.response.status && error.response.statusText && error.response.data  && error.response.data.error) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    // console.log(error.response); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    console.log('=============================== Axios Error ===============================') 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    console.log(error.response); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    console.log(error.response.data.error); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    errorText = `status : ${error.response.status} - ${error.response.statusText}<br>message : ${error.response.data.error.message}`; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  else { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    console.log('================================ Error =====================================') 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    console.log(error); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    errorText = error; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  return errorText; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+} 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 serverApp.post('/api/makeWord',  
														 | 
														
														 | 
														
															 serverApp.post('/api/makeWord',  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     isAuthenticated, 
														 | 
														
														 | 
														
															     isAuthenticated, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     isAccessTokens, 
														 | 
														
														 | 
														
															     isAccessTokens, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     async (req, res, next)=>{ 
														 | 
														
														 | 
														
															     async (req, res, next)=>{ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-      const fileOptions = { headers: { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        Authorization: `Bearer ${req.session.accessToken}`, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        "Content-Type" : file.mimeType 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-      }} 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-      const {siteId, itemId, name} = req.body; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      const options = { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        headers: { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          Authorization: `Bearer ${req.session.accessToken}`, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        }, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      }; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      const {siteId, path, name} = req.body; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       const doc = new Document({ 
														 | 
														
														 | 
														
															       const doc = new Document({ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         sections : [ 
														 | 
														
														 | 
														
															         sections : [ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															           { 
														 | 
														
														 | 
														
															           { 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -356,17 +393,32 @@ serverApp.post('/api/makeWord', 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             ] 
														 | 
														
														 | 
														
															             ] 
														 | 
													
												
											
												
													
														| 
														 | 
														
															           } 
														 | 
														
														 | 
														
															           } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         ] 
														 | 
														
														 | 
														
															         ] 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-      }) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-      try{ 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        await axios.put(endPoint + "/sites/"+ siteId +"/drive/items/"+itemId+':/'+name+':/content', file.buffer, fileOptions); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-      } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-      catch(error) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        console.log(error.response.data.error);  
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        next(error); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        // resultObj.success = 'F'; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        // resultObj.message = '선택하신 파일 정보 삭제중 오류가 발생하였습니다.\n' + error.response.data.error.message; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        // return res.json(resultObj); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-      } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      }); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      Packer.toBuffer(doc).then(async (buffer)=>{ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        const resultObj = {message:"", success: 'F'};; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        try{ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          const sitesInfo = await axios.get(endPoint + "/sites/"+ siteId + path, options); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          if (sitesInfo.data && sitesInfo.data.id) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            const itemId = sitesInfo.data.id; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            const result = await axios.put(endPoint + "/sites/"+ siteId +"/drive/items/"+itemId+':/'+name+':/content', buffer, options); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            if (result.data) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+              resultObj.message = "요청하신 Word 파일이 생성되었습니다.<br>파일명 : "+ name; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+              resultObj.success = 'S'; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            else { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+              resultObj.message = "요청하신 Word 파일이 생성되지 않았습니다."; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          else { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            resultObj.message = "생성할 폴더 경로를 찾을 수 없습니다."; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        catch(error) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          resultObj.message = "요청하신 Word 파일 생성 중 오류가 발생하였습니다.<br>" + getErrorMessage(error); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        res.send(resultObj); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      }); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 }) 
														 | 
														
														 | 
														
															 }) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 serverApp.post('/api/makeExcel',  
														 | 
														
														 | 
														
															 serverApp.post('/api/makeExcel',  
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -376,7 +428,6 @@ serverApp.post('/api/makeExcel', 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															       const fileOptions = { headers: { 
														 | 
														
														 | 
														
															       const fileOptions = { headers: { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         Authorization: `Bearer ${req.session.accessToken}`, 
														 | 
														
														 | 
														
															         Authorization: `Bearer ${req.session.accessToken}`, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        "Content-Type" : 'application/ms-excel' 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       }} 
														 | 
														
														 | 
														
															       }} 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															       const options = { headers: { 
														 | 
														
														 | 
														
															       const options = { headers: { 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -385,27 +436,58 @@ serverApp.post('/api/makeExcel', 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       const {siteId, path, name} = req.body; 
														 | 
														
														 | 
														
															       const {siteId, path, name} = req.body; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       const wb = XLSX.utils.book_new(); 
														 | 
														
														 | 
														
															       const wb = XLSX.utils.book_new(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       XLSX.utils.book_append_sheet(wb, XLSX.utils.json_to_sheet([]), 'Sheet1'); 
														 | 
														
														 | 
														
															       XLSX.utils.book_append_sheet(wb, XLSX.utils.json_to_sheet([]), 'Sheet1'); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-      XLSX.writeFile(wb, name); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-      const data = fs.readFileSync(name); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      var wbout = XLSX.write(wb, {bookType:'xlsx',  type: 'buffer'}); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      const resultObj = {message:'', success: 'F'}; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       try{ 
														 | 
														
														 | 
														
															       try{ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         const parentData = await axios.get(endPoint + "/sites/"+ siteId +path, options); 
														 | 
														
														 | 
														
															         const parentData = await axios.get(endPoint + "/sites/"+ siteId +path, options); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         if (parentData.data) { 
														 | 
														
														 | 
														
															         if (parentData.data) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-          const result = await axios.put(endPoint + "/sites/"+ siteId +"/drive/items/"+parentData.data.id+':/'+name+':/content', data, fileOptions); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-          fs.unlinkSync(name); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          const result = await axios.put(endPoint + "/sites/"+ siteId +"/drive/items/"+parentData.data.id+':/'+name+':/content', wbout, options); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															           if (result.data) { 
														 | 
														
														 | 
														
															           if (result.data) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            return res.json({message:'요청하신 Excel 파일이 생성 되었습니다.', success: 'S'}); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            resultObj.message ='요청하신 Excel 파일이 생성 되었습니다.'; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            resultObj.success = 'S'; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          else{ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            resultObj.message = '요청하신 Excel 파일이 생성 되지 않았습니다.'; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															           } 
														 | 
														
														 | 
														
															           } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-          return res.json({message:'요청하신 Excel 파일이 생성 되지 않았습니다.', success: 'F'}); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       } 
														 | 
														
														 | 
														
															       } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       catch(error) { 
														 | 
														
														 | 
														
															       catch(error) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        console.log(error.response.data.error);  
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        return res.json({message:'요청하신 Excel 파일 생성 중 오류가 발생하였습니다.', success: 'F', error: error}); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        // next(error); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        // resultObj.success = 'F'; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        // resultObj.message = '선택하신 파일 정보 삭제중 오류가 발생하였습니다.\n' + error.response.data.error.message; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        // return res.json(resultObj); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        resultObj.message = "요청하신 Word 파일 생성 중 오류가 발생하였습니다.<br>" + getErrorMessage(error); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       } 
														 | 
														
														 | 
														
															       } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      res.json(resultObj); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+}) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+serverApp.post('/api/makePptx',  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    isAuthenticated, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    isAccessTokens, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    async (req, res, next)=>{ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      const options = { headers: { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        Authorization: `Bearer ${req.session.accessToken}`, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      }} 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      const {siteId, path, name} = req.body; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      const pres = new pptxgen(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      pres.addSlide("TITLE_SLIDE"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      const resultObj = {message:'', success: 'F'}; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      pres.stream().then(async (data)=>{ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        try{ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          const parentData = await axios.get(endPoint + "/sites/"+ siteId +path, options); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          if (parentData.data) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            const result = await axios.put(endPoint + "/sites/"+ siteId +"/drive/items/"+parentData.data.id+':/'+name+':/content', data, options); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            if (result.data) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+              resultObj.message ='요청하신 PowerPoint 프레젠테이션 파일이 생성 되었습니다.'; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+              resultObj.success = 'S'; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            else{ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+              resultObj.message = '요청하신 PowerPoint 프레젠테이션 파일이 생성 되지 않았습니다.'; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        catch(error) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          resultObj.message = "요청하신 PowerPoint 프레젠테이션 파일 생성 중 오류가 발생하였습니다.<br>" + getErrorMessage(error); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        res.json(resultObj); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      }) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 }) 
														 | 
														
														 | 
														
															 }) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 serverApp.post('/api/check-name',  
														 | 
														
														 | 
														
															 serverApp.post('/api/check-name',  
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -460,19 +542,141 @@ serverApp.post('/api/check-name', 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       } 
														 | 
														
														 | 
														
															       } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 }) 
														 | 
														
														 | 
														
															 }) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+// serverApp.post('/api/upload', upload.array('file'), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//   isAuthenticated, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//   isAccessTokens, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//   async (req, res, next)=>{ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//     const startTime = new Date(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//     const folderParam = { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//       name: '', 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//       folder: { }, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//       '@microsoft.graph.conflictBehavior': 'rename' 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//     } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//     const files = req.files; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//     let {siteId, path, folder} = req.body; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//     if (siteId && path) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//       const options = { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//         headers: { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//           Authorization: `Bearer ${req.session.accessToken}`, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//         }, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//       }; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//         if (folder) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//           if (!Array.isArray(folder)) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//             folder = [folder]; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//           } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//           let beforeUri = ''; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//           let beforeItemId = ''; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//           for (let item of folder) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//             const fileInfo = JSON.parse(item); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//             const param = {...folderParam}; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//             param.name = fileInfo.name; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//             let folderPath = ''; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//             if (fileInfo.path) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//               folderPath = fileInfo.path;  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//               if (!path.includes(':')) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                 folderPath = ":" + folderPath; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//               } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//             } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//             let uri = endPoint + "/sites/"+ siteId + path + folderPath; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//             try { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+               
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//               let itemId = ''; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//               if (beforeUri === uri) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                 itemId = beforeItemId; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//               } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//               else { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                 const sitesInfo = await axios.get(uri, options); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                 itemId = sitesInfo.data.id; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                 beforeItemId = itemId; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                 beforeUri = uri; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//               } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//               await axios.post(endPoint + "/sites/"+ siteId +"/drive/items/" + itemId +"/children", param, options); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//             } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//             catch(error) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//               return res.json({success:'F', message: '요청하신 파일 업로드 중 오류가 발생하였습니다.<br>' + getErrorMessage(error)}); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//             } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//           } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//         if (files && files.length > 0) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//           const promiseArray = []; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//           let beforeUri = ''; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//           let beforeItemId = ''; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//           for (let file of files) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//             // const fileName = file.originalname.substring(0, file.originalname.lastIndexOf('.')); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//             const fileName = file.originalname; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//             let filePath = req.body[ fileName + "_path"]; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//             file.originalname = Buffer.from(file.originalname, 'ascii').toString('utf8'); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//             let formatPath = ''; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//             if (filePath) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//               if (Array.isArray(filePath) && filePath.length > 0) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                 formatPath = filePath[0]; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                 if (filePath.length > 1) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                   req.body[ fileName + "_path"] = filePath.splice(1);  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//               } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//               else if (filePath.trim()){ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                 formatPath = filePath; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                 if (!path.includes(":")) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                   formatPath = ":" + formatPath; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//               } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//               let itemId = ''; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//               const uri = endPoint + "/sites/"+ siteId + path + formatPath; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+               
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//               if (beforeUri === uri) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                 itemId = beforeItemId; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//               } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//               else { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                 const sitesInfo = await axios.get(uri, options); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                 itemId = sitesInfo.data.id; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                 beforeUri = uri; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                 beforeItemId = itemId;  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//               } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//               const fileOptions = { headers: { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                 Authorization: `Bearer ${req.session.accessToken}`, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                 "Content-Type" : file.mimeType 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//               }} 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//               // await axios.put(endPoint + "/sites/"+ siteId +"/drive/items/"+itemId+':/'+file.originalname+':/content', file.buffer, fileOptions); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//               promiseArray.push(axios.put(endPoint + "/sites/"+ siteId +"/drive/items/"+itemId+':/'+file.originalname+':/content', file.buffer, fileOptions)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//           } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//           if (promiseArray.length > 0) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//             try { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//               const result = await Promise.all(promiseArray); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//               console.log(result.length); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//             } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//             catch(error){ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//               return res.json({success:'F', message: '요청하신 파일 업로드 중 오류가 발생하였습니다.<br>' + getErrorMessage(error)}); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//             } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//           } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//         const endTime = new Date(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//         let betweenTime = endTime - startTime; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//         if (betweenTime > 60000) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//           betweenTime = (betweenTime/1000/60) + ' 분'; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//         else { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//           betweenTime = (betweenTime/1000) + ' 초';        
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//         console.log('시작 시간 :', startTime.toLocaleString(), ', 종료 시간 :', endTime.toLocaleString(), ', 소요 시간 :', betweenTime); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//         res.json({success:'S', message: '요청하신 파일 업로드가 정상적으로 처리 되었습니다.'}); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//       } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+// }); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 serverApp.post('/api/upload', upload.array('file'), 
														 | 
														
														 | 
														
															 serverApp.post('/api/upload', upload.array('file'), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   isAuthenticated, 
														 | 
														
														 | 
														
															   isAuthenticated, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   isAccessTokens, 
														 | 
														
														 | 
														
															   isAccessTokens, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   async (req, res, next)=>{ 
														 | 
														
														 | 
														
															   async (req, res, next)=>{ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     const startTime = new Date(); 
														 | 
														
														 | 
														
															     const startTime = new Date(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    const folderParam = { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-      name: '', 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-      folder: { }, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-      '@microsoft.graph.conflictBehavior': 'rename' 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     const files = req.files; 
														 | 
														
														 | 
														
															     const files = req.files; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     let {siteId, path, folder} = req.body; 
														 | 
														
														 | 
														
															     let {siteId, path, folder} = req.body; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     if (siteId && path) { 
														 | 
														
														 | 
														
															     if (siteId && path) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       const options = { 
														 | 
														
														 | 
														
															       const options = { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         headers: { 
														 | 
														
														 | 
														
															         headers: { 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -488,8 +692,13 @@ serverApp.post('/api/upload', upload.array('file'), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															           let beforeItemId = ''; 
														 | 
														
														 | 
														
															           let beforeItemId = ''; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															           for (let item of folder) { 
														 | 
														
														 | 
														
															           for (let item of folder) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             const fileInfo = JSON.parse(item); 
														 | 
														
														 | 
														
															             const fileInfo = JSON.parse(item); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            const param = {...folderParam}; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            param.name = fileInfo.name; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            const param = { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+              name: fileInfo.name, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+              folder: {}, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+              '@microsoft.graph.conflictBehavior': 'rename' 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            }; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             let folderPath = ''; 
														 | 
														
														 | 
														
															             let folderPath = ''; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             if (fileInfo.path) { 
														 | 
														
														 | 
														
															             if (fileInfo.path) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															               folderPath = fileInfo.path;  
														 | 
														
														 | 
														
															               folderPath = fileInfo.path;  
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -500,55 +709,88 @@ serverApp.post('/api/upload', upload.array('file'), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             let uri = endPoint + "/sites/"+ siteId + path + folderPath; 
														 | 
														
														 | 
														
															             let uri = endPoint + "/sites/"+ siteId + path + folderPath; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             try { 
														 | 
														
														 | 
														
															             try { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                
														 | 
														
														 | 
														
															                
														 | 
													
												
											
												
													
														| 
														 | 
														
															-              let itemId = ''; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-              if (beforeUri === uri) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                itemId = beforeItemId; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-              } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-              else { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                const sitesInfo = await axios.get(uri, options); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                itemId = sitesInfo.data.id; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                beforeItemId = itemId; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                beforeUri = uri; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-              } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-              await axios.post(endPoint + "/sites/"+ siteId +"/drive/items/" + itemId +"/children", param, options); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-               
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-              // await axios.post(endPoint + "/sites/"+ siteId +"/drive/items/" + itemId +"/children", param, options); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+              // let itemId = ''; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+              // if (beforeUri === uri) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+              //   itemId = beforeItemId; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+              // } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+              // else { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+              //   const sitesInfo = await axios.get(uri, options); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+              //   itemId = sitesInfo.data.id; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+              //   beforeItemId = itemId; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+              //   beforeUri = uri; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+              // } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+              const result = await new Promise (async (resolve, reject)=>{ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                try { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                  const sitesInfo = await axios.get(uri, options); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                  resolve(sitesInfo.data); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                catch(error) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                  if (error.response) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    reject(error.response); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                  } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                  else { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    reject(error); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                  } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+              }).then(async (result)=>{ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                return await new Promise(async (resolve, reject)=>{ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                  try { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    const uploadFolder = await axios.post(endPoint + "/sites/"+ siteId +"/drive/items/" + result.id +"/children", param, options); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    resolve(uploadFolder.data); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                  } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                  catch(error){ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    if (error.response) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                      reject(error.response); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    else { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                      reject(error); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                  } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                }) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+              }).catch((error)=>{ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                console.log(error); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+              }) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+              console.log(result.createdDateTime); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+              // console.log(result); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             } 
														 | 
														
														 | 
														
															             } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             catch(error) { 
														 | 
														
														 | 
														
															             catch(error) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-              if (error.response) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                console.log(error.response.data); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-              }  
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-              else { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                console.log(error); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-              } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                // next(error); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-              return res.json({success:'F', message: '요청하신 파일 업로드 중 오류가 발생하였습니다.', error : error}); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+              return res.json({success:'F', message: '요청하신 파일 업로드 중 오류가 발생하였습니다.<br>' + getErrorMessage(error)}); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             } 
														 | 
														
														 | 
														
															             } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															           } 
														 | 
														
														 | 
														
															           } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          const makeFolderTime = new Date(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          let betweenTime = makeFolderTime - startTime; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          if (betweenTime > 60000) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            betweenTime = (betweenTime/1000/60) + ' 분'; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          else { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            betweenTime = (betweenTime/1000) + ' 초';        
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          console.log('폴더 시작 시간 :', startTime.toLocaleString(), ', 폴더 종료 시간 :', makeFolderTime.toLocaleString(), ', 소요 시간 :', betweenTime); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        const promiseArray = []; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         if (files && files.length > 0) { 
														 | 
														
														 | 
														
															         if (files && files.length > 0) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-          const promiseArray = []; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															           let beforeUri = ''; 
														 | 
														
														 | 
														
															           let beforeUri = ''; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															           let beforeItemId = ''; 
														 | 
														
														 | 
														
															           let beforeItemId = ''; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															           for (let file of files) { 
														 | 
														
														 | 
														
															           for (let file of files) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            // const fileName = file.originalname.substring(0, file.originalname.lastIndexOf('.')); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             const fileName = file.originalname; 
														 | 
														
														 | 
														
															             const fileName = file.originalname; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             let filePath = req.body[ fileName + "_path"]; 
														 | 
														
														 | 
														
															             let filePath = req.body[ fileName + "_path"]; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             file.originalname = Buffer.from(file.originalname, 'ascii').toString('utf8'); 
														 | 
														
														 | 
														
															             file.originalname = Buffer.from(file.originalname, 'ascii').toString('utf8'); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            try {  
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-              let formatPath = ''; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-              if (filePath) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                if (Array.isArray(filePath) && filePath.length > 0) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                  formatPath = filePath[0]; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                  if (filePath.length > 1) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    req.body[ fileName + "_path"] = filePath.splice(1);  
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                  } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            let formatPath = ''; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            if (filePath) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+              if (Array.isArray(filePath) && filePath.length > 0) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                formatPath = filePath[0]; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                if (filePath.length > 1) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                  req.body[ fileName + "_path"] = filePath.splice(1);  
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 } 
														 | 
														
														 | 
														
															                 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                else if (filePath.trim()){ 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                  formatPath = filePath; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+              } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+              else if (filePath.trim()){ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                formatPath = filePath; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 } 
														 | 
														
														 | 
														
															                 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 if (!path.includes(":")) { 
														 | 
														
														 | 
														
															                 if (!path.includes(":")) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                   formatPath = ":" + formatPath; 
														 | 
														
														 | 
														
															                   formatPath = ":" + formatPath; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 } 
														 | 
														
														 | 
														
															                 } 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -565,28 +807,31 @@ serverApp.post('/api/upload', upload.array('file'), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 beforeUri = uri; 
														 | 
														
														 | 
														
															                 beforeUri = uri; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 beforeItemId = itemId;  
														 | 
														
														 | 
														
															                 beforeItemId = itemId;  
														 | 
													
												
											
												
													
														| 
														 | 
														
															               } 
														 | 
														
														 | 
														
															               } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-              // const uploadUri = endPoint + "/sites/"+ siteId +"/drive/items/"+itemId+':/'+file.originalname+':/content'; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															               const fileOptions = { headers: { 
														 | 
														
														 | 
														
															               const fileOptions = { headers: { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 Authorization: `Bearer ${req.session.accessToken}`, 
														 | 
														
														 | 
														
															                 Authorization: `Bearer ${req.session.accessToken}`, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 "Content-Type" : file.mimeType 
														 | 
														
														 | 
														
															                 "Content-Type" : file.mimeType 
														 | 
													
												
											
												
													
														| 
														 | 
														
															               }} 
														 | 
														
														 | 
														
															               }} 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-              await axios.put(endPoint + "/sites/"+ siteId +"/drive/items/"+itemId+':/'+file.originalname+':/content', file.buffer, fileOptions); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            catch(error) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-              if (error) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                if (error.response) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                  console.log(error.response.data); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                }  
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                else { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                  console.log(error); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-              } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-              return res.json({success:'F', message: '요청하신파일 업로드 중 오류가 발생하였습니다.', error : error}); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+              // await axios.put(endPoint + "/sites/"+ siteId +"/drive/items/"+itemId+':/'+file.originalname+':/content', file.buffer, fileOptions); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+              promiseArray.push(axios.put(endPoint + "/sites/"+ siteId +"/drive/items/"+itemId+':/'+file.originalname+':/content', file.buffer, fileOptions)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        if (promiseArray.length > 0) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          try { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            const result = await Promise.all(promiseArray); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          catch(error){ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            return res.json({success:'F', message: '요청하신 파일 업로드 중 오류가 발생하였습니다.<br>' + getErrorMessage(error)}); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															           } 
														 | 
														
														 | 
														
															           } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         const endTime = new Date(); 
														 | 
														
														 | 
														
															         const endTime = new Date(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        console.log('시작 시간 :', startTime, '종료 시간 :', endTime); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        let betweenTime = endTime - startTime; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        if (betweenTime > 60000) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          betweenTime = (betweenTime/1000/60) + ' 분'; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        else { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          betweenTime = (betweenTime/1000) + ' 초';        
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        console.log('시작 시간 :', startTime.toLocaleString(), ', 종료 시간 :', endTime.toLocaleString(), ', 소요 시간 :', betweenTime); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         res.json({success:'S', message: '요청하신 파일 업로드가 정상적으로 처리 되었습니다.'}); 
														 | 
														
														 | 
														
															         res.json({success:'S', message: '요청하신 파일 업로드가 정상적으로 처리 되었습니다.'}); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       } 
														 | 
														
														 | 
														
															       } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 }); 
														 | 
														
														 | 
														
															 }); 
														 |