Laravel S3 | InvalidArgumentException

Laravel S3 | InvalidArgumentException

I have a laravel project on my local and on the staging server. It works on remote, but I have a problem on my local windows 10 pro machine.

I have a laravel project on my local and on the staging server. It works on remote, but I have a problem on my local windows 10 pro machine.

Here is an error in this line.

 $uploadPath = Storage::disk('s3')->put("$storagePath/$saveName", $file, 'public');

As long as it works on remote, I think that the problem is with environment, but where... I've compared my .env with other team members. It's the same. I've made composer install, composer update, php artisan config:clear - no result.

exception: "InvalidArgumentException"
file: "E:\repos\dcp-laravel\vendor\laravel\framework\src\Illuminate\Http\JsonResponse.php"
line: 75
message: "Type is not supported"
trace: [{file: "E:\repos\dcp-laravel\vendor\symfony\http-foundation\JsonResponse.php", line: 50,…},…]
0: {file: "E:\repos\dcp-laravel\vendor\symfony\http-foundation\JsonResponse.php", line: 50,…}
1: {file: "E:\repos\dcp-laravel\vendor\laravel\framework\src\Illuminate\Http\JsonResponse.php", line: 31,…}
2: {file: "E:\repos\dcp-laravel\vendor\laravel\framework\src\Illuminate\Routing\ResponseFactory.php",…}
3: {file: "E:\repos\dcp-laravel\app\Helpers\Traits\APIResponse.php", line: 43, function: "json",…}
4: {file: "E:\repos\dcp-laravel\app\Http\Controllers\FileUploaders\ProposalCoverController.php", line: 59,…}
5: {function: "upload", class: "App\Http\Controllers\FileUploaders\ProposalCoverController", type: "->"}
6: {file: "E:\repos\dcp-laravel\vendor\laravel\framework\src\Illuminate\Routing\Controller.php", line: 54,…}
7: {,…}
8: {file: "E:\repos\dcp-laravel\vendor\laravel\framework\src\Illuminate\Routing\Route.php", line: 212,…}
9: {file: "E:\repos\dcp-laravel\vendor\laravel\framework\src\Illuminate\Routing\Route.php", line: 169,…}
10: {file: "E:\repos\dcp-laravel\vendor\laravel\framework\src\Illuminate\Routing\Router.php", line: 665,…}
11: {file: "E:\repos\dcp-laravel\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php", line: 30,…}
12: {,…}
13: {file: "E:\repos\dcp-laravel\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php", line: 151,…}
14: {file: "E:\repos\dcp-laravel\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php", line: 53,…}
15: {,…}
16: {file: "E:\repos\dcp-laravel\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php", line: 151,…}
17: {file: "E:\repos\dcp-laravel\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php", line: 53,…}
18: {,…}
19: {file: "E:\repos\dcp-laravel\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php", line: 151,…}
20: {file: "E:\repos\dcp-laravel\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php", line: 53,…}
21: {file: "E:\repos\dcp-laravel\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php", line: 104,…}
22: {file: "E:\repos\dcp-laravel\vendor\laravel\framework\src\Illuminate\Routing\Router.php", line: 667,…}
23: {file: "E:\repos\dcp-laravel\vendor\laravel\framework\src\Illuminate\Routing\Router.php", line: 642,…}
24: {file: "E:\repos\dcp-laravel\vendor\laravel\framework\src\Illuminate\Routing\Router.php", line: 608,…}
25: {file: "E:\repos\dcp-laravel\vendor\laravel\framework\src\Illuminate\Routing\Router.php", line: 597,…}
26: {file: "E:\repos\dcp-laravel\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php",…}
27: {file: "E:\repos\dcp-laravel\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php", line: 30,…}
28: {file: "E:\repos\dcp-laravel\vendor\fideloper\proxy\src\TrustProxies.php", line: 57,…}
29: {file: "E:\repos\dcp-laravel\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php", line: 151,…}
30: {file: "E:\repos\dcp-laravel\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php", line: 53,…}
31: {,…}
32: {file: "E:\repos\dcp-laravel\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php", line: 151,…}
33: {file: "E:\repos\dcp-laravel\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php", line: 53,…}
34: {,…}
35: {file: "E:\repos\dcp-laravel\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php", line: 151,…}
36: {file: "E:\repos\dcp-laravel\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php", line: 53,…}
37: {,…}
38: {file: "E:\repos\dcp-laravel\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php", line: 151,…}
39: {file: "E:\repos\dcp-laravel\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php", line: 53,…}
40: {,…}
41: {file: "E:\repos\dcp-laravel\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php", line: 151,…}
42: {file: "E:\repos\dcp-laravel\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php", line: 53,…}
43: {file: "E:\repos\dcp-laravel\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php", line: 104,…}
44: {file: "E:\repos\dcp-laravel\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php",…}
45: {file: "E:\repos\dcp-laravel\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php",…}
46: {file: "E:\repos\dcp-laravel\public\index.php", line: 55, function: "handle",…}
47: {file: "E:\repos\dcp-laravel\server.php", line: 21, function: "require_once"}

[email protected]

public function upload(ProposalUpdateCover $request)
{
    try {
        $file = $this->coverUploader->upload($request->file('cover'), $this::DEFAULT_UPLOAD_PATH);
        return $this->success_response($file->toArray());
    } catch (\Throwable $exception) {
        return $this->error_response($exception);
    }
}

coverUploader->upload

public function upload(UploadedFile $file, $storagePath = 'file')
{
    $saveName = $this->fileName($file);

    /** Save file to s3 */
    /* !!! Error is here !!!*/
    $uploadPath = Storage::disk('s3')->put("$storagePath/$saveName", $file, 'public');
    $publicUrl = env('AWS_URL').$uploadPath;

    /** Set cover_url - public url */
    $this->file->setAttribute('file_url', $publicUrl);
    /** Set cover_rel - relative path needed for delete file needs */
    $this->file->setAttribute('file_rel', $uploadPath);
    $this->file->save();
    return $this->file;
}

php laravel

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Php how to delete multiple rows through checkbox using ajax in laravel

In this article i will let you know to delete multiple rows through checkbox using ajax in laravel and before delete we will give a confirmation message.

5 Laravel’s Hidden Gems

Spread the love1. Stop on first validation error By default, Laravel will check for all validation rules and return a list of errors. But if you want to stop this process after first validation failure, that’s how you can achieve…Read More→

Some of the most frequent how tos in Laravel

Spread the loveHow to get relationship from relationship using With() in Laravel Some times there are cases where you want to get relationship from relationship in Laravel, that can be achieved via following: How to create multiple where clauses in…Read More→

10 Laravel Quick Tips

Spread the loveTip 1. Controllers Having Single Action In some situations you need a single action in a controller, if this is the case in Laravel you can achieve it by __invoke() method. Routes: Artisan command to generate this controller:…Read More→

Laravel Sanctum vs Passport

After the Laravel Sanctum package was released? Everywhere question was asked that When to use Sanctum and when to use Passport? So, in this video, you will ...