async function uploadPhotos(names, tempdir) { console.log(`Выгружаю чанк`); const token = 'eyJhbGciOiJSUzUxMiIsInR5cCI6IkpXVCIsImtpZCI6IjFrYnhacFJNQGJSI0tSbE1xS1lqIn0.eyJ1c2VyIjoibWIzNzk1OCIsInR5cGUiOiJhcGlfa2V5IiwicG9ydGFsX3Rva2VuIjoiNjM5MjE2NzUtMGZiNC00Y2I0LWFhM2EtMDAxMzQxYWY4NDlmIiwiYXBpX2tleV9pZCI6Ijg5ZWVmNGI4LWYyZTgtNDM2Zi05ODQ5LWFmYjk0ZTUzZWEwZiIsImlhdCI6MTcxNjM3OTQwMH0.JAkoA0f5itHmy6lDXeaOL2L2tPOrrqCfRzwkBYhdu21jsFjUjtI5y7JQ9Bno6N19kaUb9e2gEtcf4K0EzhGXmwMNHtOaQe_xW7W7II_ERCgViBJWaN5Vfo5G4GzaxclW4vMnbeL3hNngHDpn9 - _l - 8TIeFnEfL9knk6OQh4swtdoGgmJdF2uyPqcD0rWafAlNQ22LR4Ufupl-hswIKIl8JUy4AuUAfQHZmfj833YdQgbg8UNbtkVR6tfxuzXisS8DfrofYRZl4ie98_1KKx66riY1SH1wmsylLvmVsgpvL0F3qjHPhsJoHr7VJT_kUPMnij0MWYquT7c3AdAwNe - ZPACzXPa77qAKdMOQM9HL7oIfWjqUNwd8vyFsl - SJElM - ZJUxGSO7bmVItzWuUm4KX7vw3iZzfoD8vxh6G5tOAyn3_J9MJiFSEGUf3poS7rlV711VJOFnQayvIVoHdj95PyLJqZn4153MkI4llGKfk5wrGbwE - 0MX7DPxDFq0fi2'; const formData = new FormData(); names.forEach(name => { const filePath = path.join(tempdir, name); formData.append('files', fs.readFileSync(filePath), name); }); const config = { headers: { ...formData.getHeaders(), Authorization: `Bearer ${token}`, }, maxContentLength: Infinity, maxBodyLength: Infinity, adapter: 'http' }; const i = axios.create({ httpsAgent: new https.Agent({ keepAlive: false, maxSockets: 10 }) }); const apiUrl = "https://api.timeweb.cloud/api/v1/storages/buckets/293797/object-manager/upload"; try { const date = new Date(); console.log(date.getHours(), date.getMinutes()); await i.post(apiUrl, formData, config); } catch (error) { const date = new Date(); console.log(date.getHours(), date.getMinutes()); console.error('Error uploading photos:', error); throw new Error(error); } }
Обсуждают сегодня