Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to stream to an Amazon S3 bucket #2249

Closed
thmnrtn opened this issue Aug 4, 2021 · 1 comment
Closed

Ability to stream to an Amazon S3 bucket #2249

thmnrtn opened this issue Aug 4, 2021 · 1 comment

Comments

@thmnrtn
Copy link

thmnrtn commented Aug 4, 2021

This is:

- [] a bug report
- [x] a feature request
- [x] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

What is the expected behavior?

Able to stream a file to an Amazon S3 bucket using the writer object

What is the current behavior?

It currently fails on the line below in \PhpOffice\PhpSpreadsheet\Writer\BaseWriter because Amazon S3 buckets don't support fopen in wb+ mode (see Amazon S3 docs).

<?php
$fileHandle = $filename ? fopen($filename, 'wb+') : false;

The error thrown is from Amazon S3 is:

Mode not supported: wb+. Use one 'r', 'w', 'a', or 'x'.

Using wb mode instead works but I don't have a detailed enough understanding of PhpSpreadsheet to be sure that it wouldn't break anything else.

What are the steps to reproduce?

Create an spreadsheet object and attempt to wrote to an Amazon S3 bucket using the writer object.

Please provide a Minimal, Complete, and Verifiable example of code that exhibits the issue without relying on an external Excel file or a web server:

<?php

require __DIR__ . '/vendor/autoload.php';

// Create new Spreadsheet object
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();

$spreadsheet->getActiveSheet()->setCellValue('Test');

$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);

$write->save('s3://mybucket/myfile.xlsx');

Which versions of PhpSpreadsheet and PHP are affected?

I'm using PHP 7.3.4 and PHPSpreadsheet 1.18.0

@PowerKiKi
Copy link
Member

Fixed in 1.19.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants