|
10 | 10 | use Illuminate\Queue\InteractsWithQueue; |
11 | 11 | use Illuminate\Queue\SerializesModels; |
12 | 12 | use Illuminate\Support\Collection; |
| 13 | +use Illuminate\Support\Facades\Log; |
13 | 14 | use Illuminate\Support\Facades\Storage; |
14 | 15 | use Illuminate\Support\Str; |
15 | 16 | use Laravel\Nova\Actions\Action; |
@@ -185,15 +186,28 @@ protected function storeFile(UploadedFile|string $file, string $destination, str |
185 | 186 | return null; |
186 | 187 | } |
187 | 188 |
|
| 189 | + $targetPath = $destination . '/' . $finalFileName; |
188 | 190 | $stream = Storage::disk($data->disk)->readStream($data->path); |
189 | | - if ($stream === false) { |
190 | | - return null; |
191 | | - } |
192 | 191 |
|
193 | | - $targetPath = $destination . '/' . $finalFileName; |
194 | | - $stored = Storage::disk('resources')->put($targetPath, $stream, 'public'); |
195 | 192 | if (is_resource($stream)) { |
196 | | - fclose($stream); |
| 193 | + try { |
| 194 | + $stored = Storage::disk('resources')->writeStream($targetPath, $stream, ['visibility' => 'public']); |
| 195 | + } finally { |
| 196 | + fclose($stream); |
| 197 | + } |
| 198 | + } else { |
| 199 | + // Some environments return null instead of a stream for temp files. |
| 200 | + // Fallback to reading file contents directly. |
| 201 | + $contents = Storage::disk($data->disk)->get($data->path); |
| 202 | + if (!is_string($contents) || $contents === '') { |
| 203 | + Log::warning('[BulkUploadMediaFiles] Unable to read temp file contents', [ |
| 204 | + 'disk' => $data->disk, |
| 205 | + 'path' => $data->path, |
| 206 | + ]); |
| 207 | + return null; |
| 208 | + } |
| 209 | + |
| 210 | + $stored = Storage::disk('resources')->put($targetPath, $contents, 'public'); |
197 | 211 | } |
198 | 212 |
|
199 | 213 | // Clean temporary Filepond directory. |
|
0 commit comments