diff --git a/back-end-cf/index.js b/back-end-cf/index.js index 9c8591e4..e4c23ad8 100644 --- a/back-end-cf/index.js +++ b/back-end-cf/index.js @@ -43,7 +43,6 @@ const PATH_AUTH_STATES = Object.freeze({ async function handleRequest(request) { let queryString, querySplited, requestPath; - let abnormalWay = false; const returnHeaders = { 'Access-Control-Allow-Origin': '*', 'Cache-Control': 'max-age=3600', @@ -55,10 +54,9 @@ async function handleRequest(request) { queryString = decodeURIComponent( 'file=/' + request.url.split('://')[1].split(/\/(.+)/)[1] ); - abnormalWay = true; } if (queryString) querySplited = queryString.split('='); - if ((querySplited && querySplited[0] === 'file') || abnormalWay) { + if ((querySplited && querySplited[0] === 'file')) { const file = querySplited[1]; const fileName = file.split('/').pop(); if (fileName.toLowerCase() === PASSWD_FILENAME.toLowerCase()) @@ -279,10 +277,10 @@ async function uploadFiles(fileJsonList) { const batchRequest = { requests: fileList.map((file, index) => ({ id: `${index + 1}`, - method: 'POST', + method: file['fileSize'] ? 'POST' : 'PUT', url: `/me/drive/root:${encodeURI( EXPOSE_PATH + file['remotePath'] - )}:/createUploadSession`, + )}${file['fileSize'] ? ':/createUploadSession' : ':/content'}`, headers: { 'Content-Type': 'application/json' }, body: {}, })), diff --git a/front-end/index.html b/front-end/index.html index abf88a97..248b5886 100644 --- a/front-end/index.html +++ b/front-end/index.html @@ -15,9 +15,6 @@ // window.GLOBAL_CONFIG.SCF_GATEWAY += "/fodi/"; // window.GLOBAL_CONFIG.IS_CF = false; // } - // if (location.protocol === 'http:') { - // location.href = location.href.replace(/http/, 'https'); - // } ({ remotePath: `${odPath}/${f.webkitRelativePath || f.name}`, + fileSize: f.size ? 1 : 0, })); function paginate(array, size) { @@ -1750,7 +1722,7 @@ } if (fileSize === 0) { - progressText.innerHTML = `${file.name}: 0 byte, skipped.`; + progressText.innerHTML = `${file.name}: Upload completed!`; } else { progressText.innerHTML += ' Upload completed!'; }