Skip to content

[FEATURE] Ability to stream to an Amazon S3 bucket #2326

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

Merged
merged 2 commits into from
Oct 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ and this project adheres to [Semantic Versioning](https://semver.org).
- More flexibility in the StringValueBinder to determine what datatypes should be treated as strings [PR #2138](https://github.com/PHPOffice/PhpSpreadsheet/pull/2138)
- Helper class for conversion between css size Units of measure (`px`, `pt`, `pc`, `in`, `cm`, `mm`). [PR #2152](https://github.com/PHPOffice/PhpSpreadsheet/issues/2145)
- Allow Row height and Column Width to be set using different units of measure (`px`, `pt`, `pc`, `in`, `cm`, `mm`), rather than only in points or MS Excel column width units. [PR #2152](https://github.com/PHPOffice/PhpSpreadsheet/issues/2145)
- Ability to stream to an Amazon S3 bucket
[Issue #2249](https://github.com/PHPOffice/PhpSpreadsheet/issues/2249)

### Changed

Expand Down
7 changes: 6 additions & 1 deletion src/PhpSpreadsheet/Writer/BaseWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,12 @@ public function openFileHandle($filename): void
return;
}

$fileHandle = $filename ? fopen($filename, 'wb+') : false;
$mode = 'wb+';
$scheme = parse_url($filename, PHP_URL_SCHEME);
if ($scheme === 's3') {
$mode = 'w';
}
$fileHandle = $filename ? fopen($filename, $mode) : false;
if ($fileHandle === false) {
throw new Exception('Could not open file "' . $filename . '" for writing.');
}
Expand Down