I'm trying to upload a file to my Laravel 8 API which will eventually be consumed via a job and processed. I'm using Laravel's Storage method, and have a POST
endpoint with a controller action to import my file.
However, when trying this through Postman, I get the following error:
Call to a member function storeAs() on null
What am I missing from my Postman config to get the file?
My controller:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\File;
use Illuminate\Support\Facades\Storage;
use Illuminate\Http\Request;
class CsvController extends Controller
{
/**
* Import CSV
*
* @param Request $request
* @return Response
*/
public function import(Request $request)
{
$someID = 5;
$request->file('csv')->storeAs(
'bulk-csvs', $someID
);
// Storage::disk('local')->put('example.txt', 'Contents');
return response()->json([
'file' => $request->file('csv'),
'success' => true,
'message' => 'CSV imported'
], 200);
}
}
And my Postman config: