首页 > 解决方案 > 使用容器中的 fs.writefile 写入已安装的 DFS 时出错

问题描述

我正在使用fs.writeFile. 99% 的时间writefile可以正常工作,但有时会返回错误。在代码中,我创建了文件并且不再访问它。也没有其他东西可以访问该文件。

try {
     result = await this.writeFile(location, fileContent);
     this.logger.info('File got released successfully');
     } catch (error) {
     .....
     }
async writeFile(location, content) {
        const self = this;
        self.logger.info(`Creating the following file ${location}`);

        return new Promise(function(resolve, reject) {
            fs.writeFile(location, content, (err) => {
                if (err) {
                    self.logger.error(`Error creating file in the cloud at ${location}. Error: ${err}`);
                    const errMsg = `Error creating file in the cloud at ${location}. Error: ${err}`;
                    reject(errMsg);
                } else {
                    self.logger.info(`Successfully created ${location}`);
                    resolve(null);
                }
            });
        });
    }

错误:EIO:i/o 错误,打开

标签: javascriptnode.jsfs

解决方案


推荐阅读