export default async(url='',file={},servletType=1)=>{ var header_content = { // 'Content-Type': 'multipart/form-data', "type":servletType, "fileid":file.fileId, "range":0, "totalsize":file.file.size, "filecreatetime":getNowFormatDate(), "filename":typeof(file.file.name) ==="undefined"?"":encodeURI(file.file.name), }; let formData = new FormData(); formData.append("file", file.file); let requestConfig = { credentials: 'include', method: 'post', headers: header_content, mode: "cors", cache: "force-cache", body: formData }; url = fileManagerIp+"filemanager/FileUploadAndDownloadServlet"; const response = await fetch(url, requestConfig); // let domResult = new DOMParser().parseFromString(response,"text/xml"); // let resultCode = domResult.getElementsByTagName("resultCode")[0].innerHTML; let resultCode = 1; if("OK" == response.statusText){ resultCode = 0; } return resultCode; } let fileManagerIp = "/"; export const prevPath = (fileId) =>{ var header_content = { "type":2, "fileid":fileId, "range":0, "filecreatetime":getNowFormatDate(), }; let formData = new FormData(); let requestConfig = { credentials: 'include', method: 'post', headers: header_content, mode: "cors", cache: "force-cache", body: formData }; let url = fileManagerIp+"filemanager/FileUploadAndDownloadServlet"; const response = fetch(url, requestConfig); // let domResult = new DOMParser().parseFromString(response,"text/xml"); // let resultCode = domResult.getElementsByTagName("resultCode")[0].innerHTML; // let resultCode = 1; // if("OK" == response.statusText){ // resultCode = 0; // } return response; } function getNowFormatDate() { /** * 获取当前时间 */ var now = new Date(); var year = now.getFullYear(); //年 var month = now.getMonth() + 1; //月 var day = now.getDate(); //日 var hh = now.getHours(); //时 var mm = now.getMinutes(); //分 var ss = now.getSeconds(); //秒 var clock = year + "-"; if(month < 10) clock += "0"; clock += month + "-"; if(day < 10) clock += "0"; clock += day + " "; if(hh < 10) clock += "0"; clock += hh + ":"; if(mm < 10) clock += '0'; clock += mm + ":"; if(ss < 10) clock += '0'; clock += ss; return(clock); }