【发布时间】:2020-12-21 18:11:49
【问题描述】:
我正在尝试自动执行从网站下载 mp3 文件并上传到另一个网站的任务。使用 Puppeteer,我可以使用以下代码做到这一点。
// ... Download the file and save locally
// Sets the value of the file input to fileToUpload
inputUploadHandle.uploadFile(fileToUpload);
// ... submit the form
这在我的 Mac 上运行良好。我可以下载文件并通过表单提交上传。当我在 Heroku 上部署它时,我知道 Heroku 的临时文件系统会将文件保存到 /app 文件夹。我什至可以通过 NodeMailer 将保存的文件作为附件发送。
但是在我的 Heroku 应用程序上,当 Puppeteer 提交表单时,文件并没有按应有的方式上传。提交就像未选择文件一样发生。
我知道我可以解决一些问题,比如从我自己的服务器上抓取文件。但我仍然很好奇为什么会发生这种情况。是什么让 Puppeteer uploadFile 在 Heroku 上失败?
顺便说一下,这里有两个链接可能对背景有所帮助:
【问题讨论】: