Need Immediate Answers? Check out our SUPPORT CENTER or CONTACT OUR SUPPORT TEAM

Accessing private Photos via ajax

Greetings,

I am developing a photo browser using JavaScript (AngularJS in my case).
Currently, I am using our own API to act as a proxy between all calls to the Zenfolio API and our JS frontend, since as far as I could tell, the API does not support AJAX requests.

I handle authentication through our API, (getting the Auth token, setting the token header with the subsequent requests, etc.) which allows me to access private Groups and PhotoSets from our Zenfolio account.

The problem arises when trying to display image thumbnails in our app.

I am using the URL address http://{UrlHost}/{UrlCore}-{Size}.jpg?sn={Sequence}&tk={UrlToken} as described in the download documentation here, but I still get the 'Content protected by Owner' instead of the actual image.

Now I know I should provide the Authentication token or a Keyring, but there is just no way as far as I can tell to do that, since I am displaying the images through the image tag, and calling every image and getting the data of each thumbnail from our API seems like too much of an overkill in this case (the sets can contain a lot of images).

I would appreciate it if someone has any ideas how I could display those Private image thumbnails.

Comments

  • WindowsPhoneWindowsPhone SwitzerlandMember Posts: 3
    edited October 2017
    Hi,
    I am developing a viewer too and ended up with UWP instead of Javascript.

    But I had your same problem. "Protected image" can be shown from different reasons:
    - user doesn't allow you to download the hd image (Size 6)
    - You don't have a cookie or header to authenticate yourself

    Check the accessdescriptor info, if there is this flag: ProtectXXLarge you have to load size 5 and not size 6.

    If you want download the image from a protected folder, you can use the keyring (it should work with JavaScript).

    In your XMLHttpRequest, you can use this function:
    xmlHttp.setRequestHeader("X-Zenfolio-Keyring",key);
    and once you are inside a protected gallery you can download all images with the same key.

  • yingdragon5yingdragon5 Member Posts: 3
    Thanks for the response, much appreciated.

    Well, I am trying to implement the browser as a feature in our app, so using another platform isn't really an option for me, sadly.

    Well the issue here is that I can not send the auth header since I am just including the src link inside the image tag.
    I've tried bypassing this via loading each image through ajax first, with the auth header, but the API does not allow preflight requests (the OPTIONS method is not allowed, when accessing the API).

    As far as downloading goes, the download works fine through our API, the issue is just displaying the image thumbs to our users beforehand.
Sign In or Register to comment.