vendredi 7 mai 2021

Loading a file from S3 | Storage and PHPExcel_Reader_Excel2007 Class

Problem Statement:

We are storing files on an S3 bucket and want to load them via ->load().

Could not open storage/app/path/file.xlsx for reading! File does not exist.


Files and Configuration:

use Illuminate\Support\Facades\Storage;
use PHPExcel_Reader_Excel2007;


      $path = Storage::disk('s3-storage')->path('app/path/' , $filename);

      $objReader = new PHPExcel_Reader_Excel2007();
      $objReader->setReadDataOnly(true);
      $objPHPExcel = $objReader->load($path);

config/filesystems.php

        's3-storage' => [
            'driver' => 's3',
            'key' => env('AWS_ACCESS_KEY_ID'),
            'secret' => env('AWS_SECRET_ACCESS_KEY'),
            'region' => env('AWS_DEFAULT_REGION'),
            'bucket' => env('AWS_BUCKET'),
            'root' => '/storage',
        ],


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire