Skip to content

Commit 1f08f16

Browse files
authored
[FEATURE] Ability to stream to an Amazon S3 bucket (#2326)
Related #2249
1 parent 86a8bbd commit 1f08f16

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ and this project adheres to [Semantic Versioning](https://semver.org).
2828
- More flexibility in the StringValueBinder to determine what datatypes should be treated as strings [PR #2138](https://github.com/PHPOffice/PhpSpreadsheet/pull/2138)
2929
- 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)
3030
- 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)
31+
- Ability to stream to an Amazon S3 bucket
32+
[Issue #2249](https://github.com/PHPOffice/PhpSpreadsheet/issues/2249)
3133

3234
### Changed
3335

src/PhpSpreadsheet/Writer/BaseWriter.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,12 @@ public function openFileHandle($filename): void
115115
return;
116116
}
117117

118-
$fileHandle = $filename ? fopen($filename, 'wb+') : false;
118+
$mode = 'wb+';
119+
$scheme = parse_url($filename, PHP_URL_SCHEME);
120+
if ($scheme === 's3') {
121+
$mode = 'w';
122+
}
123+
$fileHandle = $filename ? fopen($filename, $mode) : false;
119124
if ($fileHandle === false) {
120125
throw new Exception('Could not open file "' . $filename . '" for writing.');
121126
}

0 commit comments

Comments
 (0)