excel - Laravel Excel::Import using google cloud storage 突然停止工作,报错:mkdir(): No such file or directory
问题描述
一段时间以来,我一直在使用 Laravel 导入上传到谷歌云存储的文件。在不更改任何代码的情况下,以下调用突然停止工作。
Excel::import($importer, $document->path, env('GOOGLE_STORAGE_DISK', 'local'), $fileType);
从导入方法跟踪的返回错误如下。
"message": "mkdir(): No such file or directory",
"exception": "ErrorException",
"file": "/workspace/vendor/maatwebsite/excel/src/Files/TemporaryFileFactory.php",
"line": 52,
"trace": [
{
"function": "handleError",
"class": "Illuminate\\Foundation\\Bootstrap\\HandleExceptions",
"type": "->"
},
{
"file": "/workspace/vendor/maatwebsite/excel/src/Files/TemporaryFileFactory.php",
"line": 52,
"function": "mkdir"
},
{
"file": "/workspace/vendor/maatwebsite/excel/src/Reader.php",
"line": 398,
"function": "makeLocal",
"class": "Maatwebsite\\Excel\\Files\\TemporaryFileFactory",
"type": "->"
},
{
"file": "/workspace/vendor/maatwebsite/excel/src/Reader.php",
"line": 99,
"function": "getReader",
"class": "Maatwebsite\\Excel\\Reader",
"type": "->"
},
{
"file": "/workspace/vendor/maatwebsite/excel/src/Excel.php",
"line": 146,
"function": "read",
"class": "Maatwebsite\\Excel\\Reader",
"type": "->"
},
{
"file": "/workspace/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php",
"line": 261,
"function": "import",
"class": "Maatwebsite\\Excel\\Excel",
"type": "->"
},
{
"file": "/workspace/app/Http/Controllers/ImportController.php",
"line": 175,
"function": "__callStatic",
"class": "Illuminate\\Support\\Facades\\Facade",
"type": "::"
},
这是在 TemporaryFileFactory.php 中引发错误的行
if (!file_exists($this->temporaryPath) && !mkdir($concurrentDirectory = $this->temporaryPath) && !is_dir($concurrentDirectory)) {
我根本不知道如何开始解决这个问题。由于我没有进行任何代码更改,我只能假设某个库的新版本是罪魁祸首。但是我尝试在我的 composer.json 中对旧库版本进行硬编码
"maatwebsite/excel": "3.1.19",
并运行 composer install ,似乎没有什么区别。任何关于尝试解决这个问题的方向的任何线索都将不胜感激。
解决方案
我决定改用“/tmp”,
为此,我需要发布和更改 config/excel.php
php artisan vendor:publish –provider="Maatwebsite\Excel\ExcelServiceProvider"
编辑配置/excel.php
'local_path' => '/tmp',
推荐阅读
- linux - 如何使用原始套接字将 udp 数据包发送到具有假源 ip 和端口的本地进程
- graph - Neo4j 图形模型未训练
- shell - 关于特定 GNU Makefile 条目的问题
- datagrid - 数据网格板条箱新行
- javascript - Chart.JS 更改文本颜色
- autohotkey - RegWrite 不写入注册表
- swift - SwiftUI:超过 4 个组合的文本视图不能与视图修饰符一起使用
- android - 如何使用mysql数据库为现有网站开发应用程序
- javascript - Nuxt 中间件检查用户是否登录不工作
- boost - 如果在套接字刚刚向远程端发送消息时调用 boost::asio::ip::tcp::socket::cancel() ,为什么会发生这种情况?