File tree 3 files changed +35
-2
lines changed
3 files changed +35
-2
lines changed Original file line number Diff line number Diff line change 11
11
use Illuminate \Contracts \Support \Arrayable ;
12
12
use Illuminate \Database \Eloquent \Model ;
13
13
use Illuminate \Foundation \Bus \Dispatchable ;
14
+ use Illuminate \Http \File ;
14
15
use Illuminate \Queue \InteractsWithQueue ;
15
16
use Illuminate \Queue \SerializesModels ;
16
17
use Illuminate \Support \Arr ;
@@ -179,6 +180,10 @@ public function handle()
179
180
}
180
181
181
182
$ writer ->close ();
183
+
184
+ if ($ this ->getS3Disk ()) {
185
+ Storage::disk ($ this ->getS3Disk ())->putFileAs ('' , (new File ($ path )), $ filename );
186
+ }
182
187
}
183
188
184
189
/**
@@ -189,6 +194,14 @@ protected function getDisk(): string
189
194
return strval (config ('datatables-export.disk ' , 'local ' ));
190
195
}
191
196
197
+ /**
198
+ * @return string
199
+ */
200
+ protected function getS3Disk (): string
201
+ {
202
+ return strval (config ('datatables-export.s3_disk ' , '' ));
203
+ }
204
+
192
205
/**
193
206
* @param \Yajra\DataTables\Services\DataTable $dataTable
194
207
* @return \Illuminate\Support\Collection<array-key, Column>
Original file line number Diff line number Diff line change @@ -74,8 +74,10 @@ public function updateExportProgress(): ?StreamedResponse
74
74
75
75
public function downloadExport (): StreamedResponse
76
76
{
77
- return Storage::disk ($ this ->getDisk ())
78
- ->download ($ this ->batchJobId .'. ' .$ this ->getType (), $ this ->getFilename ());
77
+ if ($ this ->getS3Disk ()) {
78
+ return Storage::disk ($ this ->getS3Disk ())->download ($ this ->batchJobId .'. ' .$ this ->getType (), $ this ->getFilename ());
79
+ }
80
+ return Storage::disk ($ this ->getDisk ())->download ($ this ->batchJobId .'. ' .$ this ->getType (), $ this ->getFilename ());
79
81
}
80
82
81
83
protected function getType (): string
@@ -110,4 +112,12 @@ protected function getDisk(): string
110
112
111
113
return $ disk ;
112
114
}
115
+
116
+ protected function getS3Disk (): string
117
+ {
118
+ /** @var string $disk */
119
+ $ disk = config ('datatables-export.s3_disk ' , '' );
120
+
121
+ return $ disk ;
122
+ }
113
123
}
Original file line number Diff line number Diff line change 38
38
*/
39
39
'disk ' => 'local ' ,
40
40
41
+ /*
42
+ |--------------------------------------------------------------------------
43
+ | Use S3 for final file destination
44
+ |--------------------------------------------------------------------------
45
+ |
46
+ | After generating the file locally, it can be uploaded to s3.
47
+ |
48
+ */
49
+ 's3_disk ' => '' ,
50
+
41
51
/*
42
52
|--------------------------------------------------------------------------
43
53
| Default Date Format
You can’t perform that action at this time.
0 commit comments