Laravel-medialibrary: Url cannot be reached

Created on 30 Mar 2018  Â·  5Comments  Â·  Source: spatie/laravel-medialibrary

Hi, how to deal with url cannot be reached ? but i can reach it using the browser or download manager

url example https://s295.**.com/newdl/_Dfh_sI_3jUlwpAYRLl90Q/1522117054/0/1619800/1619800_1920x1080_4000k.mp4

Most helpful comment

Nevermind, I found the problem:

For some reason, it's not working if using HTTPS in local development with Laravel Valet.

I "unsecured" my local site and now it's working fine

$ art tinker
Psy Shell v0.9.9 (PHP 7.2.9 — cli) by Justin Hileman
>>> @fopen('https://fitnss.test/assets/uploads/yrRPzaw1X4Is2VctOofgw8Q5T2ZIlCMJoYYSHqCO.jpeg', 'r')
PHP Warning:  fopen(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in Psy Shell code on line 1
PHP Warning:  fopen(): Failed to enable crypto in Psy Shell code on line 1
PHP Warning:  fopen(https://fitnss.test/assets/uploads/yrRPzaw1X4Is2VctOofgw8Q5T2ZIlCMJoYYSHqCO.jpeg): failed to open stream: operation failed in Psy Shell code on line1
=> false
>>>

$ valet unsecure fitnss
Password:
Restarting php...
Restarting nginx...
The [fitnss.test] site will now serve traffic over HTTP.

$ art tinker
Psy Shell v0.9.9 (PHP 7.2.9 — cli) by Justin Hileman
>>> @fopen('http://fitnss.test/assets/uploads/yrRPzaw1X4Is2VctOofgw8Q5T2ZIlCMJoYYSHqCO.jpeg', 'r')
=> stream resource #806

All 5 comments

Which error are you getting?

Feel free to PR a failing test.

Sorry this can be closed because the url is generated based on user ip or something like that i think

I have the same issue on my local environment, really weird. On my test server it's working fine. Is it possible that the method addMediaFromUrl() is checking if the Media URL is accessible from the internet ??
cc @freekmurze

Nevermind, I found the problem:

For some reason, it's not working if using HTTPS in local development with Laravel Valet.

I "unsecured" my local site and now it's working fine

$ art tinker
Psy Shell v0.9.9 (PHP 7.2.9 — cli) by Justin Hileman
>>> @fopen('https://fitnss.test/assets/uploads/yrRPzaw1X4Is2VctOofgw8Q5T2ZIlCMJoYYSHqCO.jpeg', 'r')
PHP Warning:  fopen(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in Psy Shell code on line 1
PHP Warning:  fopen(): Failed to enable crypto in Psy Shell code on line 1
PHP Warning:  fopen(https://fitnss.test/assets/uploads/yrRPzaw1X4Is2VctOofgw8Q5T2ZIlCMJoYYSHqCO.jpeg): failed to open stream: operation failed in Psy Shell code on line1
=> false
>>>

$ valet unsecure fitnss
Password:
Restarting php...
Restarting nginx...
The [fitnss.test] site will now serve traffic over HTTP.

$ art tinker
Psy Shell v0.9.9 (PHP 7.2.9 — cli) by Justin Hileman
>>> @fopen('http://fitnss.test/assets/uploads/yrRPzaw1X4Is2VctOofgw8Q5T2ZIlCMJoYYSHqCO.jpeg', 'r')
=> stream resource #806

I have the same problem I think it is related to https when using valet may be due to an invalid certificate or something

I replaced addMediaFromUrl() method with addMedia() because I want to access file which already exists local in the project

$model->addMedia(public_path('path-to-image'))->preservingOriginal()->toMediaCollection('collection-name');

I hope it works with you.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

intrepidws picture intrepidws  Â·  3Comments

swash13 picture swash13  Â·  3Comments

denitsa-md picture denitsa-md  Â·  3Comments

jam1e picture jam1e  Â·  3Comments

stayallive picture stayallive  Â·  4Comments