0

I'm trying to upload a file doing a POST request to an API. So when I test it in Tinker it works fine, it takes like 5 seconds to upload the file, but when I test my own endpoint using Postman I get this error:

"message": "Maximum execution time of 60 seconds exceeded".

Not sure why is it working on Tinker fine but not in the app.

Here's how my request looks like:

$response = Http::attach('file', file_get_contents(asset('storage/' . $attachment->type . '/' . $attachment->name)), $attachment->name)
        ->post('https://api-example.com/endpoint', 
            [
                'uid' => env('HANDWRYTTEN_UID'),
                'type' => 'cover'
            ]);
        return $response->json();

I have cleared the cache and config like this

php artisan cache:clear

and

php artisan config:clear

Any help is very much appreciated! Thank you very much!

zlatan
  • 3,346
  • 2
  • 17
  • 35

1 Answers1

0

For some reason I tried to change the way to send file_get_contents() and I used storage_path() instead of asset() and it worked! So maybe there was an error with the file path but I wasn't getting any errors about that. It's now solved. Thank you!