SpartnerNL / Laravel-Excel

🚀 Supercharged Excel exports and imports in Laravel
https://laravel-excel.com
MIT License
12.22k stars 1.91k forks source link

[Bug]: Excel Import from Disk rewind() expects parameter 1 to be resource, bool given #3632

Closed matze1708 closed 2 years ago

matze1708 commented 2 years ago

Is the bug applicable and reproducable to the latest version of the package and hasn't it been reported before?

What version of Laravel Excel are you using?

3.1.40

What version of Laravel are you using?

8.83.7

What version of PHP are you using?

7.4

Describe your issue

Hi i use a Windows Server 2019 with IIS 10 Larvale it selve works fine. But my Import from Disk Laravel gave me this error:

rewind() expects parameter 1 to be resource, bool given i figure out it is a permission failure. I tried to change the permission on storage folder to Full Access on IIS user. But i got still the same issue. I tried to change a fastcgi setting in php.ini, but still the same error.

On my Dev System, it works fine. But on the Production Server i got this error.

Code:

Excel::import(
                new JoomlaUserImport,
                '/contacts/tmp/cron_CSV_Mitglieder_Profil.csv',
                'JoomlaExportMember',
                \Maatwebsite\Excel\Excel::CSV
            );

My laravel log:

[2022-05-26 21:18:28] local.ERROR: rewind() expects parameter 1 to be resource, bool given {"userId":1,"exception":"[object] (ErrorException(code: 0): rewind() expects parameter 1 to be resource, bool given at \vendor\league\flysystem-sftp\src\SftpAdapter.php:495) [stacktrace]

0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError()

1 \vendor\league\flysystem-sftp\src\SftpAdapter.php(495): rewind()

2 \vendor\league\flysystem\src\Filesystem.php(197): League\Flysystem\Sftp\SftpAdapter->readStream()

3 \vendor\laravel\framework\src\Illuminate\Filesystem\FilesystemAdapter.php(486): League\Flysystem\Filesystem->readStream()

4 \vendor\maatwebsite\excel\src\Files\TemporaryFile.php(59): Illuminate\Filesystem\FilesystemAdapter->readStream()

5 \vendor\maatwebsite\excel\src\Reader.php(440): Maatwebsite\Excel\Files\TemporaryFile->copyFrom()

6 \vendor\maatwebsite\excel\src\Reader.php(102): Maatwebsite\Excel\Reader->getReader()

7 \vendor\maatwebsite\excel\src\Excel.php(146): Maatwebsite\Excel\Reader->read()

8 \vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php(261): Maatwebsite\Excel\Excel->import()

9 \app\Http\Controllers\Joomla\ImportMemberfromJoomla.php(30): Illuminate\Support\Facades\Facade::__callStatic()

10 \vendor\laravel\framework\src\Illuminate\Routing\Controller.php(54): App\Http\Controllers\Joomla\ImportMemberfromJoomla->getCSVFileFromSFTP()

11 \vendor\laravel\framework\src\Illuminate\Routing\ControllerDispatcher.php(45): Illuminate\Routing\Controller->callAction()

12 \vendor\laravel\framework\src\Illuminate\Routing\Route.php(262): Illuminate\Routing\ControllerDispatcher->dispatch()

13 \vendor\laravel\framework\src\Illuminate\Routing\Route.php(205): Illuminate\Routing\Route->runController()

14 \vendor\laravel\framework\src\Illuminate\Routing\Router.php(721): Illuminate\Routing\Route->run()

15 \vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(128): Illuminate\Routing\Router->Illuminate\Routing\{closure}()

16 \vendor\laravel\framework\src\Illuminate\Routing\Middleware\SubstituteBindings.php(50): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()

17 \vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(167): Illuminate\Routing\Middleware\SubstituteBindings->handle()

18 \vendor\laravel\framework\src\Illuminate\Routing\Middleware\ThrottleRequests.php(127): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()

19 \vendor\laravel\framework\src\Illuminate\Routing\Middleware\ThrottleRequests.php(103): Illuminate\Routing\Middleware\ThrottleRequests->handleRequest()

20 \vendor\laravel\framework\src\Illuminate\Routing\Middleware\ThrottleRequests.php(55): Illuminate\Routing\Middleware\ThrottleRequests->handleRequestUsingNamedLimiter()

21 \vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(167): Illuminate\Routing\Middleware\ThrottleRequests->handle()

22 \vendor\laravel\framework\src\Illuminate\Auth\Middleware\Authenticate.php(44): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()

23 \vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(167): Illuminate\Auth\Middleware\Authenticate->handle()

24 \vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()

25 \vendor\laravel\framework\src\Illuminate\Routing\Router.php(723): Illuminate\Pipeline\Pipeline->then()

26 \vendor\laravel\framework\src\Illuminate\Routing\Router.php(698): Illuminate\Routing\Router->runRouteWithinStack()

27 \vendor\laravel\framework\src\Illuminate\Routing\Router.php(662): Illuminate\Routing\Router->runRoute()

28 \vendor\laravel\framework\src\Illuminate\Routing\Router.php(651): Illuminate\Routing\Router->dispatchToRoute()

29 \vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(167): Illuminate\Routing\Router->dispatch()

30 \vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(128): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}()

31 \vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()

32 \vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull.php(31): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle()

33 \vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(167): Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull->handle()

34 \vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()

35 \vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TrimStrings.php(40): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle()

36 \vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(167): Illuminate\Foundation\Http\Middleware\TrimStrings->handle()

37 \vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\ValidatePostSize.php(27): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()

38 \vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(167): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle()

39 \vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance.php(86): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()

40 \vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(167): Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance->handle()

41 \vendor\laravel\framework\src\Illuminate\Http\Middleware\TrustProxies.php(39): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()

42 \vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(167): Illuminate\Http\Middleware\TrustProxies->handle()

43 \vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()

44 \vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(142): Illuminate\Pipeline\Pipeline->then()

45 \vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(111): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter()

46 \public\index.php(52): Illuminate\Foundation\Http\Kernel->handle()

How can the issue be reproduced?

.

What should be the expected behaviour?

.

patrickbrouwers commented 2 years ago

Sounds like an issue with the SftpAdapter and not this package

matze1708 commented 2 years ago

Thanks for your answer.

The sftpadapter was my first idea.

i tried it, without laravel excel an dd the content, it works on production server.

but with code above, o became this error.

That was the reason why I suspected laravel-excel, or the handling with the local filesystem.

patrickbrouwers commented 2 years ago

We don't do anything special, we just call readStream on the file we expect to exist.

matze1708 commented 2 years ago

Ok thanks,

I have additional thought. It creates the temp file in the storage folder but does not write any content to it.

Thanks

Edit: and one additional thought, too... The export to the same direction (sftp) works well.

stale[bot] commented 2 years ago

This bug report has been automatically closed because it has not had recent activity. If this is still an active bug, please comment to reopen. Thank you for your contributions.