Laravel-excel: [質問]キューに入れられたチャンク読み取りジョブが失敗する

作成日 2018年10月17日  ·  21コメント  ·  ソース: Maatwebsite/Laravel-Excel

必ずお読みください:テンプレートへの入力が必要です! 十分な情報が含まれていない問題は取り上げられない可能性があります。 Laravel-Excelの貢献ガイドライン(https://laravel-excel.maatwebsite.nl/docs/3.1/getting-started/contributing)と行動規範(https://github.com/Maatwebsite/Laravel-Excel/)を読んだことがありますかblob / 3.1 / CODE_OF_CONDUCT.md)? 問題を提出することにより、すべての人に敬意を持って接することを含め、それを遵守することが期待されます。 問題の前に次のいずれかを付けてください:[バグ] [提案] [質問]。

前提条件

次の操作を行った場合は、角かっこで囲んでXを入力します。
  • []コードの外部で動作を再現できるため、問題はLaravelExcelに限定されます。
  • [x]問題がまだ提出されていないことを確認しました。
  • [x]この問題を修正するPRが提出されていないかどうかを確認しました。

バージョン

バージョン番号を証明するときは、できるだけ正確かつ完全にしてください
  • PHPバージョン:7.1.23
  • Laravelバージョン:5.6
  • パッケージバージョン:3.1.2

説明

ファイルをインポートして(.xlsx、.ods、.csvのいずれでもかまいません)、チャンクの読み取りをキューに入れようとすると、failed_jobsテーブルで次のエラーが発生してジョブが失敗します。
InvalidArgumentException: File "/tmp/SWQF2KfyI6BP0k1x" does not exist. in /home/miguel/www/html/proliste/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/File.php:137

再現する手順

この問題をどのように再現できますか? 問題を簡単に再現できるように、Excelファイルまたは複製リポジトリを提供してください。

予想される行動:

私はその仕事が失敗することなく行われることを期待した。 ジョブをキューに入れなくても問題なく動作します。

実際の動作:
failed_jobsテーブルのスタックトレース:

InvalidArgumentException: File "/tmp/SWQF2KfyI6BP0k1x" does not exist. in /home/miguel/www/html/proliste/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/File.php:137
Stack trace:
#0 /home/miguel/www/html/proliste/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx.php(389): PhpOffice\PhpSpreadsheet\Shared\File::assertFile('/tmp/SWQF2KfyI6...')
#1 /home/miguel/www/html/proliste/vendor/maatwebsite/excel/src/Jobs/ReadChunk.php(82): PhpOffice\PhpSpreadsheet\Reader\Xlsx->load('/tmp/SWQF2KfyI6...')
#2 [internal function]: Maatwebsite\Excel\Jobs\ReadChunk->handle()
#3 /home/miguel/www/html/proliste/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#4 /home/miguel/www/html/proliste/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#5 /home/miguel/www/html/proliste/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#6 /home/miguel/www/html/proliste/vendor/laravel/framework/src/Illuminate/Container/Container.php(564): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#7 /home/miguel/www/html/proliste/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(94): Illuminate\Container\Container->call(Array)
#8 /home/miguel/www/html/proliste/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\Bus\Dispatcher->Illuminate\Bus\{closure}(Object(Maatwebsite\Excel\Jobs\ReadChunk))
#9 /home/miguel/www/html/proliste/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Maatwebsite\Excel\Jobs\ReadChunk))
#10 /home/miguel/www/html/proliste/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(98): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#11 /home/miguel/www/html/proliste/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(49): Illuminate\Bus\Dispatcher->dispatchNow(Object(Maatwebsite\Excel\Jobs\ReadChunk), false)
#12 /home/miguel/www/html/proliste/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(83): Illuminate\Queue\CallQueuedHandler->call(Object(Illuminate\Queue\Jobs\DatabaseJob), Array)
#13 /home/miguel/www/html/proliste/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(326): Illuminate\Queue\Jobs\Job->fire()
#14 /home/miguel/www/html/proliste/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(276): Illuminate\Queue\Worker->process('database', Object(Illuminate\Queue\Jobs\DatabaseJob), Object(Illuminate\Queue\WorkerOptions))
#15 /home/miguel/www/html/proliste/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(118): Illuminate\Queue\Worker->runJob(Object(Illuminate\Queue\Jobs\DatabaseJob), 'database', Object(Illuminate\Queue\WorkerOptions))
#16 /home/miguel/www/html/proliste/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(101): Illuminate\Queue\Worker->daemon('database', 'default', Object(Illuminate\Queue\WorkerOptions))
#17 /home/miguel/www/html/proliste/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(85): Illuminate\Queue\Console\WorkCommand->runWorker('database', 'default')
#18 [internal function]: Illuminate\Queue\Console\WorkCommand->handle()
#19 /home/miguel/www/html/proliste/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#20 /home/miguel/www/html/proliste/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#21 /home/miguel/www/html/proliste/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#22 /home/miguel/www/html/proliste/vendor/laravel/framework/src/Illuminate/Container/Container.php(564): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#23 /home/miguel/www/html/proliste/vendor/laravel/framework/src/Illuminate/Console/Command.php(179): Illuminate\Container\Container->call(Array)
#24 /home/miguel/www/html/proliste/vendor/symfony/console/Command/Command.php(255): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#25 /home/miguel/www/html/proliste/vendor/laravel/framework/src/Illuminate/Console/Command.php(166): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#26 /home/miguel/www/html/proliste/vendor/symfony/console/Application.php(886): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#27 /home/miguel/www/html/proliste/vendor/symfony/console/Application.php(262): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#28 /home/miguel/www/html/proliste/vendor/symfony/console/Application.php(145): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#29 /home/miguel/www/html/proliste/vendor/laravel/framework/src/Illuminate/Console/Application.php(89): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#30 /home/miguel/www/html/proliste/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(122): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#31 /home/miguel/www/html/proliste/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#32 {main}

追加情報

スタックトレースから、エラーはPhpSpreadsheetから発生しているようです。読み取り/書き込み権限の問題だと思いましたが、 /tmpフォルダーは777であり、php.iniファイルはインストール以降変更されていません( upload_max_filesize post_max_size)。

私のContactsImportクラス:

<?php

namespace App\Imports;

use App\Contact;
use App\Rubric;
use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Concerns\Importable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Maatwebsite\Excel\Concerns\WithBatchInserts;
use Maatwebsite\Excel\Concerns\WithChunkReading;
use Maatwebsite\Excel\Concerns\WithHeadingRow;

class ContactsImport implements ToModel, WithBatchInserts, WithChunkReading, WithHeadingRow, ShouldQueue
{
    use Importable;

    /**
    * <strong i="10">@param</strong> array $row
    *
    * <strong i="11">@return</strong> \Illuminate\Database\Eloquent\Model|null
    */
    public function model(array $row)
    {
        if (isset($row['rubrique'])) {
            $rubric = Rubric::firstOrCreate(['name' => $row['rubrique']]);
        } else {
            $rubric = Rubric::where('name', 'AUTRE')->first();
        }

        $area_id = intval(substr($row['code_postal'], 0, 2)) !== 0 ? intval(substr($row['code_postal'], 0, 2)) : 1;

        return new Contact([
            'name' => $row['nom'],
            'address' => $row['adresse'],
            'postal_code' => $row['code_postal'],
            'city' => $row['ville'],
            'phone_number' => $row['telephone'],
            'fax_number' => $row['fax'],
            'email' => $row['email'],
            'rubric_id' => $rubric->id,
            'area_id' => $area_id
        ]);
    }

    public function batchSize(): int
    {
        return 1000;
    }

    public function chunkSize(): int
    {
        return 1000;
    }
}
cannot-reproduce

最も参考になるコメント

temp_path(https://github.com/Maatwebsite/Laravel-Excel/blob/3.1/config/excel.php#L28)をストレージフォルダーなどに変更してみてください。 あなたのために問題を解決するかもしれません。

全てのコメント21件

こんにちは@MLouis

コントローラのコードを確認していただけますか?
Importableトレイトを使用しているので、コントローラーでは使用する必要があります
(new ContactsImport)->queue('file.ext');

Importablesを参照してください

それでも問題が解決しない場合は、コントローラーのコードも投稿してください。

こんにちは@GlennM 、お返事ありがとうございます!

私のコントローラーでは、両方を試しました。

Excel::import(new ContactsImport, $request->file('liste'));
// and
(new ContactsImport)->queue($request->file('liste'));

また、ContactsImportに渡す前に、ユーザーが送信したファイルを最初に保存しようとしました。

$fileName = Str::uuid() . '.' . $request->file('liste')->getClientOriginalExtension();
$request->file('liste')->storeAs('listes', $fileName);
Excel::import(new ContactsImport, 'listes/' . $fileName);
// also tried with
(new ContactsImport)->queue('listes/' . $fileName);

しかし、それでも同じエラーが発生しますInvalidArgumentException: File "/tmp/whatever" does not exist. in /home/miguel/www/html/proliste/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/File.php:137

私のListController:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Imports\ContactsImport;
use App\Exports\ContactsExport;
use App\Contact;
use App\Rubric;
use App\Area;
use App\Cart;
use Excel;
use DB;
use App\Http\Requests\ListRequest;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;

class ListController extends Controller
{
    public function import(Request $request)
    {
        $request->validate([
            'liste' => 'required'
        ]);

        $fileName = Str::uuid() . '.' . $request->file('liste')->getClientOriginalExtension();
        $request->file('liste')->storeAs('listes', $fileName);

        (new ContactsImport)->queue('listes/' . $fileName);

        return back()->with('status', 'Liste ajoutée avec succès');
    }
}

残念ながら再現できません。

次のコードはコントローラーで機能するはずです。

namespace App\Http\Controllers;

use Illuminate\Http\Request;

public function import(Request $request)
{
    (new ContactsImport)->queue($request->file('liste'));

    return back()->with('status', 'Liste ajoutée avec succès');
}

参考までに、私は簡略化されたバージョンを使用しています。これは私のコントローラーのメソッドです。

public function process(Request $request)
{
    (new UsersImport)->queue($request->file('dataset'));

    return back()->with('success', 'All good!');
}

そして私のUsersImportクラス:

<?php

namespace App\Imports;

use App\User;
use Illuminate\Contracts\Queue\ShouldQueue;
use Maatwebsite\Excel\Concerns\Importable;
use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Concerns\WithBatchInserts;
use Maatwebsite\Excel\Concerns\WithChunkReading;
use Maatwebsite\Excel\Concerns\WithHeadingRow;

class UsersImport implements ToModel, WithHeadingRow, WithBatchInserts, WithChunkReading, ShouldQueue
{
    use Importable;

    /**
    * <strong i="13">@param</strong> array $row
    *
    * <strong i="14">@return</strong> \Illuminate\Database\Eloquent\Model|null
    */
    public function model(array $row)
    {
        return new User([
            'name' => $row['name'],
            'email' => $row['email'],
            'password' => $row['id'],
        ]);
    }

    /**
     * <strong i="15">@return</strong> int
     */
    public function batchSize(): int
    {
        return 1000;
    }

    /**
     * <strong i="16">@return</strong> int
     */
    public function chunkSize(): int
    {
        return 1000;
    }
}

ToModel代わりにToCollectionを使用して、 WithHeadingRowWithBatchInsertsWithChunkReadingImportable追加/削除しようとしましたが、成功しませんでした。 ジョブをキューに入れていない場合にのみ機能します。

そして、キューに入れられたジョブでリストをエクスポートすることに問題はありません。インポートだけが失敗します。

たぶん、問題は私の開発サーバーの設定ミスが原因ですか?

たぶん、問題は私の開発サーバーの設定ミスが原因ですか?

確かにそうかもしれません。
PHP 7.1 / Laravel5.6とPHP7.2 / Laravel 5.7でテストし、T oModelWithHeadingRowWithBatchInsertsWithChunkReadingを使用して、どちらの場合もファイルをインポートできました。 ShouldQueueImportable

ソフトウェアを商用で使用していて、入念なサポートが必要な場合、または緊急に必要な場合は、商用ベースで提供できます。 その場合は、サポートページをご覧ください。

私はリードしている可能性があります。15万行以上のキューに入れられたエクスポートを試みた後、ジョブは失敗し、同じエラーが発生しましたが、20 AppendQueryToSheetジョブの後、インポートとはすぐに
そのため、サイズ制限など、 /tmpフォルダに問題がある可能性があります。 私はDebian9を使用していますが、パーティションは3つしかありません: //tmp )、 /homeswap 、これはパーティションサイズではありません制限。

何か見つけたら最新情報をお届けします! :祈る:

__編集__
この問題の名前を[BUG]ではなく[QUESTION]に変更する必要がありますか?

temp_path(https://github.com/Maatwebsite/Laravel-Excel/blob/3.1/config/excel.php#L28)をストレージフォルダーなどに変更してみてください。 あなたのために問題を解決するかもしれません。

@patrickbrouwersに感謝します、それは私の問題を修正しました、私はエラーなしで大きなファイルをインポートおよびエクスポートすることができます!

@patrickbrouwers configexcelにtemp_pathはありません。 詳細を教えていただけますか?

@sharjeelz最新バージョンの構成ファイルがある場合は、 httpsください。現在、古いバージョンを使用しているユーザーのtemp_pathにフォールバックがあり

やあみんな、私はこれが古い問題であることを知っています。 しかし、私は非常によく似た問題を抱えているようです。 同僚と私は同じコードベースを実行していますが、「ファイルXは存在しません」と表示されますが、彼は存在しません。 設定の問題だと思います。 しかし、config / local_pathを変更しても、問題を解決することはできません。

私は本当にこれを引き起こしている可能性のある既知の問題を探しています。 私たちは両方ともMacbookでローカルにLaravelプロジェクトを実行しており、libバージョン3.1.17を使用しています

ファイル名C:UsersAshimAppDataLocalTemplaravel-excel-K6OeXpSQuAARlI0UrSeOAkFZ0kELq0Ax.xlsはOLEファイルとして認識されません

どうすればこれを解決できますか

こんにちは、私はこれと同じ問題を抱えていますが、私の質問は、インポート機能で送信したものとは異なるファイル名が表示されるのはなぜですか? 情報を読み取る一時ファイルを作成しますか?

「」
[2020-04-17 15:15:26] local.ERROR:ファイル "/tmp/laravel-excel-rKsJKI2Clu2sEV3OqMtPngacRRZd8iJM.xlsx"が存在しません。 {"exception": "[object](InvalidArgumentException(code:0):ファイル" /tmp/laravel-excel-rKsJKI2Clu2sEV3OqMtPngacRRZd8iJM.xlsx "は存在しません。/var/www/html/sites/dashboard-imprensa/vendor/ phpoffice / phpspreadsheet / src / PhpSpreadsheet / Shared / File.php:137)
[スタックトレース]

0 /var/www/html/sites/dashboard-imprensa/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx.php(327):PhpOffice \ PhpSpreadsheet \ Shared \ File :: assertFile( '/ tmp / laravel-元...')

1 /var/www/html/sites/dashboard-imprensa/vendor/maatwebsite/excel/src/Jobs/ReadChunk.php(118):PhpOffice \ PhpSpreadsheet \ Reader \ Xlsx-> load( '/ tmp / laravel-ex。 .. ')

2 [内部関数]:Maatwebsite \ Excel \ Jobs \ ReadChunk-> handle(Object(Maatwebsite \ Excel \ Transactions \ DbTransactionHandler))

3 /var/www/html/sites/dashboard-imprensa/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(32):call_user_func_array(Array、Array)

4 /var/www/html/sites/dashboard-imprensa/vendor/laravel/framework/src/Illuminate/Container/Util.php(36):Illuminate \ Container \ BoundMethod :: Illuminate \ Container \ {closure}()

5 /var/www/html/sites/dashboard-imprensa/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(90):Illuminate \ Container \ Util :: unwrapIfClosure(Object(Closure))

6 /var/www/html/sites/dashboard-imprensa/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(34):Illuminate \ Container \ BoundMethod :: callBoundMethod(Object(Illuminate \ Foundation \ Application) 、配列、オブジェクト(クロージャー))

7 /var/www/html/sites/dashboard-imprensa/vendor/laravel/framework/src/Illuminate/Container/Container.php(592):Illuminate \ Container \ BoundMethod :: call(Object(Illuminate \ Foundation \ Application) 、配列、配列、NULL)

8 /var/www/html/sites/dashboard-imprensa/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(94):Illuminate \ Container \ Container-> call(Array)

9 /var/www/html/sites/dashboard-imprensa/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128):Illuminate \ Bus \ Dispatcher-> Illuminate \ Bus \ {closure}(Object( Maatwebsite \ Excel \ Jobs \ ReadChunk))

10 /var/www/html/sites/dashboard-imprensa/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103):Illuminate \ Pipeline \ Pipeline-> Illuminate \ Pipeline \ {closure}(Object( Maatwebsite \ Excel \ Jobs \ ReadChunk))

11 /var/www/html/sites/dashboard-imprensa/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(98):Illuminate \ Pipeline \ Pipeline-> then(Object(Closure))

12 /var/www/html/sites/dashboard-imprensa/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(83):Illuminate \ Bus \ Dispatcher-> dispatchNow(Object(Maatwebsite \ Excel \ Jobs \ ReadChunk)、false)

13 /var/www/html/sites/dashboard-imprensa/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128):Illuminate \ Queue \ CallQueuedHandler-> Illuminate \ Queue \ {closure}(Object( Maatwebsite \ Excel \ Jobs \ ReadChunk))

14 /var/www/html/sites/dashboard-imprensa/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103):Illuminate \ Pipeline \ Pipeline-> Illuminate \ Pipeline \ {closure}(Object( Maatwebsite \ Excel \ Jobs \ ReadChunk))

15 /var/www/html/sites/dashboard-imprensa/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(85):Illuminate \ Pipeline \ Pipeline-> then(Object(Closure))

16 /var/www/html/sites/dashboard-imprensa/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(59):Illuminate \ Queue \ CallQueuedHandler-> dispatchThroughMiddleware(Object(Illuminate \ Queue \ Jobs \ DatabaseJob)、Object(Maatwebsite \ Excel \ Jobs \ ReadChunk))

17 /var/www/html/sites/dashboard-imprensa/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(98):Illuminate \ Queue \ CallQueuedHandler-> call(Object(Illuminate \ Queue \ Jobs \ DatabaseJob)、Array)

18 /var/www/html/sites/dashboard-imprensa/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(356):Illuminate \ Queue \ Jobs \ Job-> fire()

19 /var/www/html/sites/dashboard-imprensa/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(306):Illuminate \ Queue \ Worker-> process( 'database'、Object(Illuminate \ Queue \ Jobs \ DatabaseJob)、Object(Illuminate \ Queue \ WorkerOptions))

20 /var/www/html/sites/dashboard-imprensa/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(132):Illuminate \ Queue \ Worker-> runJob(Object(Illuminate \ Queue \ Jobs \ DatabaseJob)、 'データベース'、Object(Illuminate \ Queue \ WorkerOptions))

21 /var/www/html/sites/dashboard-imprensa/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(112):Illuminate \ Queue \ Worker->デーモン( 'データベース'、 'デフォルト'、Object(Illuminate \ Queue \ WorkerOptions))

22 /var/www/html/sites/dashboard-imprensa/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(96):Illuminate \ Queue \ Console \ WorkCommand-> runWorker( 'database'、 'ディフォルト')

23 [内部関数]:Illuminate \ Queue \ Console \ WorkCommand-> handle()

24 /var/www/html/sites/dashboard-imprensa/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(32):call_user_func_array(Array、Array)

25 /var/www/html/sites/dashboard-imprensa/vendor/laravel/framework/src/Illuminate/Container/Util.php(36):Illuminate \ Container \ BoundMethod :: Illuminate \ Container \ {closure}()

26 /var/www/html/sites/dashboard-imprensa/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(90):Illuminate \ Container \ Util :: unwrapIfClosure(Object(Closure))

27 /var/www/html/sites/dashboard-imprensa/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(34):Illuminate \ Container \ BoundMethod :: callBoundMethod(Object(Illuminate \ Foundation \ Application) 、配列、オブジェクト(クロージャー))

28 /var/www/html/sites/dashboard-imprensa/vendor/laravel/framework/src/Illuminate/Container/Container.php(592):Illuminate \ Container \ BoundMethod :: call(Object(Illuminate \ Foundation \ Application) 、配列、配列、NULL)

29 /var/www/html/sites/dashboard-imprensa/vendor/laravel/framework/src/Illuminate/Console/Command.php(134):Illuminate \ Container \ Container-> call(Array)

30 /var/www/html/sites/dashboard-imprensa/vendor/symfony/console/Command/Command.php(255):Illuminate \ Console \ Command-> execute(Object(Symfony \ Component \ Console \ Input \ ArgvInput) 、Object(Illuminate \ Console \ OutputStyle))

31 /var/www/html/sites/dashboard-imprensa/vendor/laravel/framework/src/Illuminate/Console/Command.php(121):Symfony \ Component \ Console \ Command \ Command-> run(Object(Symfony \ Component \ Console \ Input \ ArgvInput)、Object(Illuminate \ Console \ OutputStyle))

32 /var/www/html/sites/dashboard-imprensa/vendor/symfony/console/Application.php(912):Illuminate \ Console \ Command-> run(Object(Symfony \ Component \ Console \ Input \ ArgvInput)、Object (Symfony \ Component \ Console \ Output \ ConsoleOutput))

33 /var/www/html/sites/dashboard-imprensa/vendor/symfony/console/Application.php(264):Symfony \ Component \ Console \ Application-> doRunCommand(Object(Illuminate \ Queue \ Console \ WorkCommand)、Object (Symfony \ Component \ Console \ Input \ ArgvInput)、Object(Symfony \ Component \ Console \ Output \ ConsoleOutput))

34 /var/www/html/sites/dashboard-imprensa/vendor/symfony/console/Application.php(140):Symfony \ Component \ Console \ Application-> doRun(Object(Symfony \ Component \ Console \ Input \ ArgvInput) 、Object(Symfony \ Component \ Console \ Output \ ConsoleOutput))

35 /var/www/html/sites/dashboard-imprensa/vendor/laravel/framework/src/Illuminate/Console/Application.php(93):Symfony \ Component \ Console \ Application-> run(Object(Symfony \ Component \ Console \ Input \ ArgvInput)、Object(Symfony \ Component \ Console \ Output \ ConsoleOutput))

36 /var/www/html/sites/dashboard-imprensa/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(130):Illuminate \ Console \ Application-> run(Object(Symfony \ Component \ Console \ Input \ ArgvInput)、Object(Symfony \ Component \ Console \ Output \ ConsoleOutput))

37 / var / www / html / sites / dashboard-imprensa / artisan(37):Illuminate \ Foundation \ Console \ Kernel-> handle(Object(Symfony \ Component \ Console \ Input \ ArgvInput)、Object(Symfony \ Component \ Console \ Output \ ConsoleOutput))

38 {メイン}

"}
「」

これは私が受け取っているエラーですが、私が送信したファイルは「temp /12020-04.xlsx」でした。 実際にこのファイルを受信して​​いるかどうかはすでに確認しました。 それが一時を作成する場合、なぜそれはファイルを見つけることができないのですか?

別の一時フォルダーを設定してみてくださいhttps://github.com/Maatwebsite/Laravel-Excel/blob/3.1/config/excel.php#L166

こんにちは@patrickbrouwers 、迅速な対応に感謝します。 私はそれを試しましたが、それは私の問題を解決しませんでした:(

$header = (new HeadingRowImport)->toArray($request->file('arquivo'))[0][0];

$file = Storage::putFileAs(
    'temp',
    $request->file('arquivo'),
    $request->input('dashboard_id') . str_replace("/", "-", $request->input('ano_mes')) . '.' . pathinfo($request->file('arquivo')->getClientOriginalName())['extension']
);

if ($request->input('acao') == "import") {
    Excel::import((new DadosImport($request->input('ano_mes'), $request->input('dashboard_id'), $header, $file, true)), $file);
} else {
    Excel::import((new DadosImport($request->input('ano_mes'), $request->input('dashboard_id'), $header, $file)), $file);
}

これは私のインポート機能で、かなり標準的です。 ファイルは適切なフォルダに保存されます。 public_path($ file)も使ってみました。 インポートは一時ファイルを作成しますか?

私はプロジェクトを削除し、すべてを再インストールしました、そして今それはすべて働いていますハハハあなたの助けに本当に感謝します:))

エクスポートExcelにキュージョブを使用しましたが、例外が表示されるため、ジョブを実行できません。
ErrorException:fopen(/var/www/html/biomaze.ir/storage/framework/laravel-excel/laravel-excel-85fvUcwqDwshFsD4o5PWwtamG83wnzG6):ストリームを開くことができませんでした:/var/www/html/biomaze.ir/vendorでアクセスが拒否されました/ phpoffice / phpspreadsheet / src / PhpSpreadsheet / Writer / BaseWriter。 php:111

助けてください?

storageの所有者と権限を変更してみてください
sudo chown -R www-data:<your_username> storage/ && sudo chmod -R g+w storage/

同じ問題が発生します。

ホームステッド内で開発環境を実行している場合、一時ファイルは正常に作成されます(アプリは、アップロードされたcsvを確認できます)が、phpspreadsheetは、キュー内で実行しているときにファイルを見つけるのに問題があるようです。

InvalidArgumentException {#1344 #message: "File "/home/vagrant/code/storage/app/data-imports/laravel-excel-YNpPHnBtKZXaXKIbR68goCYM5qLlzUxt.csv" does not exist." #code: 0 #file: "./vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/File.php" #line: 135

キューは最初のReadChunkジョブを通過しません。 いじくり回しを使用して、このパスでfile_exists()を実行すると、ファイルはそこにあります。

誰かがこれに直面してそれを解決しましたか?

そのため、この問題は、vagrantの外部で実行されているqueue:listenコマンドが原因で発生していました。

この問題を解決するには、vagrant内からキューワーカーを実行する必要があります。

vagrant ssh
CDコード
php職人キュー:聞く

甘く働きます。

https://github.com/Maatwebsite/Laravel-Excel/blob/3.1/config/excel.php#L166

別のフォルダ@patrickbrouwersを設定するにはどうすれば

これは私の設定ファイルです

`<?php

use Maatwebsite\Excel\Excel;

return [
    'exports' => [

    /*
    |--------------------------------------------------------------------------
    | Chunk size
    |--------------------------------------------------------------------------
    |
    | When using FromQuery, the query is automatically chunked.
    | Here you can specify how big the chunk should be.
    |
    */
    'chunk_size'             => 1000,

    /*
    |--------------------------------------------------------------------------
    | Pre-calculate formulas during export
    |--------------------------------------------------------------------------
    */
    'pre_calculate_formulas' => false,

    /*
    |--------------------------------------------------------------------------
    | Enable strict null comparison
    |--------------------------------------------------------------------------
    |
    | When enabling strict null comparison empty cells ('') will
    | be added to the sheet.
    */
    'strict_null_comparison' => false,

    /*
    |--------------------------------------------------------------------------
    | CSV Settings
    |--------------------------------------------------------------------------
    |
    | Configure e.g. delimiter, enclosure and line ending for CSV exports.
    |
    */
    'csv'                    => [
        'delimiter'              => ',',
        'enclosure'              => '"',
        'line_ending'            => PHP_EOL,
        'use_bom'                => false,
        'include_separator_line' => false,
        'excel_compatibility'    => false,
    ],

    /*
    |--------------------------------------------------------------------------
    | Worksheet properties
    |--------------------------------------------------------------------------
    |
    | Configure e.g. default title, creator, subject,...
    |
    */
    'properties'             => [
        'creator'        => '',
        'lastModifiedBy' => '',
        'title'          => '',
        'description'    => '',
        'subject'        => '',
        'keywords'       => '',
        'category'       => '',
        'manager'        => '',
        'company'        => '',
    ],
],

'imports'            => [

    /*
    |--------------------------------------------------------------------------
    | Read Only
    |--------------------------------------------------------------------------
    |
    | When dealing with imports, you might only be interested in the
    | data that the sheet exists. By default we ignore all styles,
    | however if you want to do some logic based on style data
    | you can enable it by setting read_only to false.
    |
    */
    'read_only' => true,

    /*
    |--------------------------------------------------------------------------
    | Ignore Empty
    |--------------------------------------------------------------------------
    |
    | When dealing with imports, you might be interested in ignoring
    | rows that have null values or empty strings. By default rows
    | containing empty strings or empty values are not ignored but can be
    | ignored by enabling the setting ignore_empty to true.
    |
    */
    'ignore_empty' => false,

    /*
    |--------------------------------------------------------------------------
    | Heading Row Formatter
    |--------------------------------------------------------------------------
    |
    | Configure the heading row formatter.
    | Available options: none|slug|custom
    |
    */
    'heading_row' => [
        'formatter' => 'slug',
    ],

    /*
    |--------------------------------------------------------------------------
    | CSV Settings
    |--------------------------------------------------------------------------
    |
    | Configure e.g. delimiter, enclosure and line ending for CSV imports.
    |
    */
    'csv'         => [
        'delimiter'        => ',',
        'enclosure'        => '"',
        'escape_character' => '\\',
        'contiguous'       => false,
        'input_encoding'   => 'UTF-8',
    ],

    /*
    |--------------------------------------------------------------------------
    | Worksheet properties
    |--------------------------------------------------------------------------
    |
    | Configure e.g. default title, creator, subject,...
    |
    */
    'properties'  => [
        'creator'        => '',
        'lastModifiedBy' => '',
        'title'          => '',
        'description'    => '',
        'subject'        => '',
        'keywords'       => '',
        'category'       => '',
        'manager'        => '',
        'company'        => '',
    ],

],

/*
|--------------------------------------------------------------------------
| Extension detector
|--------------------------------------------------------------------------
|
| Configure here which writer/reader type should be used when the package
| needs to guess the correct type based on the extension alone.
|
*/
'extension_detector' => [
    'xlsx'     => Excel::XLSX,
    'xlsm'     => Excel::XLSX,
    'xltx'     => Excel::XLSX,
    'xltm'     => Excel::XLSX,
    'xls'      => Excel::XLS,
    'xlt'      => Excel::XLS,
    'ods'      => Excel::ODS,
    'ots'      => Excel::ODS,
    'slk'      => Excel::SLK,
    'xml'      => Excel::XML,
    'gnumeric' => Excel::GNUMERIC,
    'htm'      => Excel::HTML,
    'html'     => Excel::HTML,
    'csv'      => Excel::CSV,
    'tsv'      => Excel::TSV,

    /*
    |--------------------------------------------------------------------------
    | PDF Extension
    |--------------------------------------------------------------------------
    |
    | Configure here which Pdf driver should be used by default.
    | Available options: Excel::MPDF | Excel::TCPDF | Excel::DOMPDF
    |
    */
    'pdf'      => Excel::DOMPDF,
],

/*
|--------------------------------------------------------------------------
| Value Binder
|--------------------------------------------------------------------------
|
| PhpSpreadsheet offers a way to hook into the process of a value being
| written to a cell. In there some assumptions are made on how the
| value should be formatted. If you want to change those defaults,
| you can implement your own default value binder.
|
| Possible value binders:
|
| [x] Maatwebsite\Excel\DefaultValueBinder::class
| [x] PhpOffice\PhpSpreadsheet\Cell\StringValueBinder::class
| [x] PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder::class
|
*/
'value_binder' => [
    'default' => Maatwebsite\Excel\DefaultValueBinder::class,
],

'cache' => [
    /*
    |--------------------------------------------------------------------------
    | Default cell caching driver
    |--------------------------------------------------------------------------
    |
    | By default PhpSpreadsheet keeps all cell values in memory, however when
    | dealing with large files, this might result into memory issues. If you
    | want to mitigate that, you can configure a cell caching driver here.
    | When using the illuminate driver, it will store each value in a the
    | cache store. This can slow down the process, because it needs to
    | store each value. You can use the "batch" store if you want to
    | only persist to the store when the memory limit is reached.
    |
    | Drivers: memory|illuminate|batch
    |
    */
    'driver'     => 'memory',

    /*
    |--------------------------------------------------------------------------
    | Batch memory caching
    |--------------------------------------------------------------------------
    |
    | When dealing with the "batch" caching driver, it will only
    | persist to the store when the memory limit is reached.
    | Here you can tweak the memory limit to your liking.
    |
    */
    'batch'     => [
        'memory_limit' => 60000,
    ],

    /*
    |--------------------------------------------------------------------------
    | Illuminate cache
    |--------------------------------------------------------------------------
    |
    | When using the "illuminate" caching driver, it will automatically use
    | your default cache store. However if you prefer to have the cell
    | cache on a separate store, you can configure the store name here.
    | You can use any store defined in your cache config. When leaving
    | at "null" it will use the default store.
    |
    */
    'illuminate' => [
        'store' => null,
    ],
],

/*
|--------------------------------------------------------------------------
| Transaction Handler
|--------------------------------------------------------------------------
|
| By default the import is wrapped in a transaction. This is useful
| for when an import may fail and you want to retry it. With the
| transactions, the previous import gets rolled-back.
|
| You can disable the transaction handler by setting this to null.
| Or you can choose a custom made transaction handler here.
|
| Supported handlers: null|db
|
*/
'transactions' => [
    'handler' => 'db',
],

'temporary_files' => [

    /*
    |--------------------------------------------------------------------------
    | Local Temporary Path
    |--------------------------------------------------------------------------
    |
    | When exporting and importing files, we use a temporary file, before
    | storing reading or downloading. Here you can customize that path.
    |
    */
    'local_path'          => storage_path('framework/laravel-excel'),

    /*
    |--------------------------------------------------------------------------
    | Remote Temporary Disk
    |--------------------------------------------------------------------------
    |
    | When dealing with a multi server setup with queues in which you
    | cannot rely on having a shared local temporary path, you might
    | want to store the temporary file on a shared disk. During the
    | queue executing, we'll retrieve the temporary file from that
    | location instead. When left to null, it will always use
    | the local path. This setting only has effect when using
    | in conjunction with queued imports and exports.
    |
    */
    'remote_disk'         => null,
    'remote_prefix'       => null,

    /*
    |--------------------------------------------------------------------------
    | Force Resync
    |--------------------------------------------------------------------------
    |
    | When dealing with a multi server setup as above, it's possible
    | for the clean up that occurs after entire queue has been run to only
    | cleanup the server that the last AfterImportJob runs on. The rest of the server
    | would still have the local temporary file stored on it. In this case your
    | local storage limits can be exceeded and future imports won't be processed.
    | To mitigate this you can set this config value to be true, so that after every
    | queued chunk is processed the local temporary file is deleted on the server that
    | processed it.
    |
    */
    'force_resync_remote' => null,
    ],
];

`

このページは役に立ちましたか?
0 / 5 - 0 評価