0

Running PHP on App Engine, Laravel 5.1.

The app is failing on \Excel::load($path); statement but afterwards when I look at the App Engine storage path the file is there. Here is the code:

        $file = $file->move($destPath,$filename);

        $path = $file->getPathname();
        if (in_array($file->getExtension(), ['xlsx', 'xlsm', 'xltx', 'xltm', 'xls', 'xlt'])){
            $newFile = \Excel::load($path); //FAILS HERE
            $info = $newFile->store('csv', storage_path('imports'), true);
            \File::delete($path);
            $path = $info['full'];
        }

I tried putting a sleep between the file->move statement but that didn't have any effect.

Any suggestions would be appreciated.

Since this was first posted here's what we've tried.

  1. We tried uploading a spreadsheet directly (by passing the $file->move) and loading that. Didn't work.
  2. On the theory the Open Office was writing a file that wasn't compatible, we tried a file that was save using Excel. Didn't work.
  3. On the theory that an Excel5 file didn't work, we tried Excel2007. Didn't work.
  4. Tested a simple fopen, fget, fseek. That worked.

Here's the stack trace.

in Excel2007.php line 82
at PHPExcel_Reader_Excel2007->canRead('/base/data/home/apps/s~populous-2-0/20170914t111153.404103259874586280/gs://populous-2-0.appspot.com/storage/imports/staff_import_17_1505402010.xlsx') in FormatIdentifier.php line 249
at FormatIdentifier->canRead('Excel2007', '/base/data/home/apps/s~populous-2-0/20170914t111153.404103259874586280/gs://populous-2-0.appspot.com/storage/imports/staff_import_17_1505402010.xlsx') in FormatIdentifier.php line 51
at FormatIdentifier->getFormatByFile('/base/data/home/apps/s~populous-2-0/20170914t111153.404103259874586280/gs://populous-2-0.appspot.com/storage/imports/staff_import_17_1505402010.xlsx') in LaravelExcelReader.php line 1341
at LaravelExcelReader->_setFormat() in LaravelExcelReader.php line 777
at LaravelExcelReader->_init('gs://populous-2-0.appspot.com/storage/imports/staff_import_17_1505402010.xlsx', null, false) in LaravelExcelReader.php line 275
at LaravelExcelReader->load('gs://populous-2-0.appspot.com/storage/imports/staff_import_17_1505402010.xlsx', null, false, null) in Excel.php line 119
at Excel->load('gs://populous-2-0.appspot.com/storage/imports/staff_import_17_1505402010.xlsx') in Facade.php line 215
at Facade::__callStatic('load', array('gs://populous-2-0.appspot.com/storage/imports/staff_import_17_1505402010.xlsx')) in StaffController.php line 173
at Excel::load('gs://populous-2-0.appspot.com/storage/imports/staff_import_17_1505402010.xlsx') in StaffController.php line 173
Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97
JohnL
  • 13,682
  • 4
  • 19
  • 23
  • What's the Exception you're getting? – ishegg Sep 13 '17 at 20:38
  • Where is your `$destPath`? Is it on the server, or cloud storage or where? Excel::load() requires a filestream that supports `fseek()` – Mark Baker Sep 13 '17 at 21:41
  • It's in GAE storage. And the specific exception is PHPExcel_Reader_Exception. – JohnL Sep 14 '17 at 12:54
  • GAE appears to support fseek(), so that may not be the issue. I created a simple test with an fopen(), fget(), fseek() of an existing file and it did not fail. – JohnL Sep 14 '17 at 13:29
  • We finally jettisoned Larvel-Excel and went with phpexcel. Even then we had to adjust their cord code changing a fopen("myFilepath","w+") to a plain fopen("myFilepath","w"). While this does not solve the original question it ended up being our go around. – JohnL Sep 14 '17 at 19:41

0 Answers0