[Cubicweb] Preview with ViewerJS in CW

Christophe de Vienne christophe at unlish.com
Sun Apr 3 15:34:04 CEST 2016



Le 03/04/2016 11:58, Stéphane Bugat a écrit :
> 
>>> Christophe, this did not work neither... However the error message is
>>> now "cette ressource est introuvable" (bad resource location). The
>>> number of parent dirs '../' does not have any effect.
>> Is this message displayed by ViewerJS which try to access the resource,
>> or by the browser who cannot load ViewerJS itself ?
>>
>> If the former, try adding/removing '../'s, and have a look at the
>> 'network' tab of the browser devtools so you get an idea of what URL the
>> viewer is actually hitting.
>>
>> If the later, where did you extract ViewerJS sources ?
> 
> Christophe, thanks for those tips. ViewerJS was extracted into the data/
> directory of the cube. Viewing
> http://myserver:8080/data/0a6bfcf4ea4e36b05a5bacb5e843de69/ViewerJS/index.html
> gives no error (but displays an empty view). The network tab of the
> devtools shows that the GET of index.html is OK.
> 
> I've tried to copy foo.pdf into the data/ directory and view
> http://myserver:8080/data/0a6bfcf4ea4e36b05a5bacb5e843de69/ViewerJS/index.html/#../../../foo.pdf
> (so that the PDF file is no more in the database but in an accessible
> part of the cube), but the GET method always returns an error 403
> (forbidden). This is also independant of the number of '../'. Removing
> 'index.html' does not change anything. Trying to view any other
> accessible file (for instance those in wdoc/) always gives the same
> error...

On what exact URL do you get a 403 (look at the network tab) ? Play with
the ../ until the URL accessed by ViewerJS is the right one (by that I
mean the URL of the file when it is stored in the database, like
/file/xxx/raw/file.ext).

You can also try the replace the '(../)*' with a single '/' which should
mean "back to the top level path" (not sure if ViewserJS likes it though).

If you still get a 403 on a URL that you can otherwise access, check if
the authentication cookies are correctly set on the request made by
ViewerJS.



-- 
Christophe de Vienne
Co-fondateur http://unli.sh



More information about the Cubicweb mailing list