File tree Expand file tree Collapse file tree 3 files changed +35
-2
lines changed Expand file tree Collapse file tree 3 files changed +35
-2
lines changed Original file line number Diff line number Diff line change 1111use Illuminate \Contracts \Support \Arrayable ;
1212use Illuminate \Database \Eloquent \Model ;
1313use Illuminate \Foundation \Bus \Dispatchable ;
14+ use Illuminate \Http \File ;
1415use Illuminate \Queue \InteractsWithQueue ;
1516use Illuminate \Queue \SerializesModels ;
1617use Illuminate \Support \Arr ;
@@ -179,6 +180,10 @@ public function handle()
179180 }
180181
181182 $ writer ->close ();
183+
184+ if ($ this ->getS3Disk ()) {
185+ Storage::disk ($ this ->getS3Disk ())->put ($ filename , (new File ($ path ))->getContent ());
186+ }
182187 }
183188
184189 /**
@@ -189,6 +194,14 @@ protected function getDisk(): string
189194 return strval (config ('datatables-export.disk ' , 'local ' ));
190195 }
191196
197+ /**
198+ * @return string
199+ */
200+ protected function getS3Disk (): string
201+ {
202+ return strval (config ('datatables-export.s3_disk ' , '' ));
203+ }
204+
192205 /**
193206 * @param \Yajra\DataTables\Services\DataTable $dataTable
194207 * @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
7474
7575 public function downloadExport (): StreamedResponse
7676 {
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 ());
7981 }
8082
8183 protected function getType (): string
@@ -110,4 +112,12 @@ protected function getDisk(): string
110112
111113 return $ disk ;
112114 }
115+
116+ protected function getS3Disk (): string
117+ {
118+ /** @var string $disk */
119+ $ disk = config ('datatables-export.s3_disk ' , '' );
120+
121+ return $ disk ;
122+ }
113123}
Original file line number Diff line number Diff line change 3838 */
3939 'disk ' => 'local ' ,
4040
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+
4151 /*
4252 |--------------------------------------------------------------------------
4353 | Default Date Format
You can’t perform that action at this time.
0 commit comments