使用Powershell上传APK文件

时间:2019-10-18 10:10:51

标签: powershell file upload

我一直试图将APK文件上传到Node.js服务器。但是最终结果不可用(61.8 MB),而原始文件是(62.6 MB)。

我的想法很简单。

我想运行一个powershell脚本,将APK文件发布到Node JS服务器,该服务器将把该文件写入目录。

但是,尽管我能够发送文件,但在此过程中它已损坏,在我看来,这很可能是编码问题,但目前我还不知道。

这是我的nodejs服务器中的上传处理程序:

app.post("/upload", (req,res) => {
  console.log('hello');
    let body = '';
    req.on('data', chunk => {
        body += chunk.toString();
    });
    req.on('end', () => {
      fs.writeFile(__dirname + '/uploads/my.apk', body,'binary',function(err) {
        if( err ) {
          res.end('not okay');
        } else {
          res.end('ok');
        }
      });
    });
});

这是我的Powershell

$FilePath = 'dir\myApk.apk';

$URI = 'http://myUrl/upload';

$response = Invoke-WebRequest -Uri $URI -Method Post -InFile $FilePath -ContentType "application/octet-stream";

有人知道发生了什么事吗?

0 个答案:

没有答案
相关问题