node.js - 使用 axios 制作 Azure Zip Deploy
问题描述
一直在努力解决这个问题,因此我需要向 Azure Zip Deploy 发出发布请求以将我的应用程序放在那里,从诸如凭据错误(已修复)之类的错误到现在的状态
axios({
headers: { "Content-Type": "'application/json'" },
method: "post",
url: 'https://test.scm.azurewebsites.net/api/zipdeploy',
auth: {
username: '',
password: ''
},
body: {
file: filePath
}
});
错误我收到
消息:'发生错误。',ExceptionMessage:'试图将文件指针移动到文件开头之前。\r\n'
中央目录损坏
解决方案
尝试这个:
const axios = require('axios');
const fs = require('fs');
siteName = '<your web app name>'
user = '<depolyment user name>'
pwd = '<password>'
ZipPath = '<depolyment zip path>'
stream = fs.createReadStream(ZipPath)
axios({
headers: { "Content-Type": "application/x-zip-compressed" },
method: "post",
url: 'https://'+siteName+'.scm.azurewebsites.net/api/zipdeploy',
auth: {
username: user,
password: pwd
},
data: stream
})
我使用静态 HTML 网站部署 .zip 文件进行测试: