Laravel Nova - JSON file when uploaded converts to TXT file

Viewed 323

I have a file field in my Nova resource for uploading JSON file. When I try to upload a JSON file it some how converts to txt before storing in database. So when I try to download it, I`m getting a txt file instead of JSON file.

Any idea why Nova converts JSON to TXT internally? Am I missing anything? I`m completely lost here.

File::make('File name')->disk('public')

Following the screenshot just after uploading JSON file. But as you can see, it shows as a .txt file.

enter image description here

1 Answers

This can be fixed by updating the code in the following way

File::make('Data','json_data')->disk('public')
            ->storeAs(function (Request $request) {
                return $request->json_data->getClientOriginalName();
            })
Related