Open Notmarrco opened 12 years ago
@Notmarrco Is the page you're on using SSL? pathOriginal
should use whatever the current page is on as it is a relative path.
Also, we have a new URL to download the original photo that might resolve your issue. It's not yet in the master branch though.
yep the all site is using ssl. Furthermore the download url is "https://mydomain.com/photo/7o/download", in https too.
ok, then I will wait until you release this new url. :)
Hrm, that is the new URL I'm referring to. Back to your original error...
PHP Warning: fopen(http://mydomain.com/photos/original/201208/blabla.jpg): failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found
Does the file exist at that location? Obviously not, but I'm starting to wonder why.
Nope, the file doesn't exist at that location. However it does exist at the url with "https" !
ok, something strange : when I call https://mydomain.com/photo/7o/view.json
, the pathOriginal isn't relative, it's http://mydomain.com/photos/original/201208/blabla.jpg
, where I expected /original/201208/blabla.jpg
.
pathOriginal is correct in the DB.
Am I wrong or is there something weird ?
I've failed to trace to the point where the "http://mydomain.com/" is added :(
@Notmarrco if you look at the view.json
endpoint there should be a host
value. That's what is prepended to the path. Can you confirm? The host
is stored with the photo record. If you're using MySql it's in the photo table.
@jmathai yep, the host value in the view.json
is the same as the one in mysql, but it's mydomain.com/photos
.
No 'http'/'https'.
diving back into it :)
I just found that in models/Photo.php
, the view function calls $this->generateUrlBase($photo)
and $this->generateUrlOriginal($photo)
.
I think that these 2 functions should be called with $protocol
as second param. Without it the default is "http", and that's why my "pathOriginal" and "pathBase" are wrong in the view.json
. Was it made on purpose ?
Still it doesn't work yet, because fopen isn't authorized (error 401) to call 'https://mydomain.com/blabla". :(
This leads to my other question : why do we use the full pathOriginal in FileSystemLocal.php ? it make more sense to me to use a relative local path, isn't it ? it would at least have better performance.
In the meantime i'll see if i can tweek my lighttpd to access the file anyway :)
As a workaround I added a new field in view.json : pathOriginalLocal
, in addApiUrls. It's a copy of pathOriginal
, before the $protocol
and $host
are added to it.
Then I call fopen( self::normalizePath($photo['pathOriginalLocal']), 'r');
instead of pathOriginal
in FileSystemLocal.php
.
I'm not sure if it's a good way to do it, so i'll wait for your opinion before i send a pull request. :)
@Notmarrco Adding $protocol
sounds like the right thing to do (I have to have a closer look at why we weren't already).
Can you open a separate issue about the use of fopen
and a URL instead of a local path? There's probably a reason but we can discuss it in a separate thread.
Hello,
I can't download the original photo when using ssl on my domain + self hosting.
The issue seems to be that it's looking for the "http" url instead of the "https" one :
called here
libraries/adapters/FileSystemLocal.php
on line 52 :What can I do to make it call the right url with "https" ?
thx