我已经承诺 fs.mkdir()。当我尝试在 /tmp 中创建单个目录时,它可以工作,但是当我尝试创建嵌套目录时收到 ENOENT 错误,即使我发送了{ recursive: true }
选项。
const mkdirAsync = util.promisify(fs.mkdir);
...
const ensureDir = ({ logger, createError }, event) => mkdirAsync(`/tmp/${event.mediaAssetUuid}/variants`, { recursive: true }).catch((err) => {
if (err.code !== 'EEXIST') {
const err2 = createError(
err,
{ logger },
`Internal Server Error. Error generating image variant for file: ${event.mediaAssetUuid}`,
null,
);
throw err2;
}
});
错误:
{
"jse_shortmsg": "Internal Server Error. Error generating image variant for file: 83ec01d8-8978-4eb0-9b0b-304f1e65cb14",
"jse_cause": {
"errno": -2,
"code": "ENOENT",
"syscall": "mkdir",
"path": "/tmp/83ec01d8-8978-4eb0-9b0b-304f1e65cb14/variants"
},