6
6
use Illuminate \Filesystem \FilesystemAdapter ;
7
7
use Illuminate \Support \Arr ;
8
8
use Illuminate \Support \Enumerable ;
9
+ use Illuminate \Support \Facades \Log ;
9
10
use Illuminate \Support \Facades \Storage ;
10
11
use Illuminate \Support \Str ;
11
12
use League \Csv \CannotInsertRecord ;
12
13
use League \Csv \EncloseField ;
13
14
use League \Csv \Writer ;
14
- use League \Flysystem \Adapter \Local ;
15
+ use League \Flysystem \FilesystemException ;
16
+ use League \Flysystem \Local \LocalFilesystemAdapter ;
17
+ use RealMediaTechnicStaudacher \LaravelFlatfiles \StreamFilters \RemoveSequence ;
15
18
use RuntimeException ;
16
19
use Symfony \Component \HttpFoundation \BinaryFileResponse ;
17
20
use Symfony \Component \HttpFoundation \StreamedResponse ;
@@ -177,14 +180,17 @@ public function moveToTarget(): bool
177
180
$ this ->addBomIfNeeded ();
178
181
179
182
/** @noinspection PhpUndefinedMethodInspection */
180
- if ($ this ->disk ->getAdapter () instanceof Local
183
+ if ($ this ->disk ->getAdapter () instanceof LocalFilesystemAdapter
181
184
&& $ this ->disk ->path ($ this ->pathToFileOnDisk ) === $ this ->pathToLocalTmpFile ) {
182
185
// No temp file that has be moved
183
186
return true ;
184
187
}
185
188
186
- if ($ this ->disk ->putStream ($ this ->pathToFileOnDisk , fopen ($ this ->pathToLocalTmpFile , 'rb ' ))) {
187
- return unlink ($ this ->pathToLocalTmpFile );
189
+ try {
190
+ $ this ->disk ->writeStream ($ this ->pathToFileOnDisk , fopen ($ this ->pathToLocalTmpFile , 'rb ' ));
191
+ unlink ($ this ->pathToLocalTmpFile );
192
+ } catch (FilesystemException $ e ) {
193
+ Log::error ('Could not write file ' .$ e ->getMessage ());
188
194
}
189
195
190
196
return false ;
@@ -198,7 +204,7 @@ private function determineDefaultWriter(): FlatfileExport
198
204
case 'csv ' :
199
205
if (!$ this ->pathToLocalTmpFile ) {
200
206
/** @noinspection PhpUndefinedMethodInspection */
201
- if ($ this ->disk ->getAdapter () instanceof Local ) {
207
+ if ($ this ->disk ->getAdapter () instanceof LocalFilesystemAdapter ) {
202
208
$ this ->pathToLocalTmpFile = $ this ->disk ->path ($ this ->pathToFileOnDisk );
203
209
204
210
$ localFileDirectory = pathinfo ($ this ->pathToLocalTmpFile , PATHINFO_DIRNAME );
0 commit comments