Wow this is cool! I’m not the most knowledgeable person to answer this (@cristi or @dimitrie, please correct me if I’m wrong) but here it goes:
The preview service is run as a separate module from the server. You can get the preview image for any stream like this onehttps://speckle.xyz/streams/81d2f2c135 using the /preview/STREAM_ID url:
I’m fairly certain the route structure is the same as for the stream url. So just replacing streams for preview should do the trick to get the image. See a specific branch preview:
How the system understands by the URL that I have access to this stream icon ? The security mechanism seems confusing to me. Below I have managed also to do also a listing widget for the streams inside unreal.
If the stream is public, the url will just work. If you need to access private streams, then you’d need to fetch the image while passing your auth token. If no token is found, it will default to the “This stream is private” image of the Red speckle cube.
In our frontend, you’ll find a component called PreviewImage.vue that has the functionality you are looking for
Basically, we fetch the image, create a temporary url for it and assign it to the <img/>src tag.
Notice that if a token exists on that session, we pass it into the headers. If no token exists we try anyway, but request may end up with the red speckle logo
Hope that helps! @dimitrie, feel free to correct me if anything I said was not acurate
Sounds correct from my end. I think possibly the trick lies into how those images are requested within the unreal ui. The blob url dance won’t be applicable there. The blue brick though makes me think that the preview for those stream is not ready yet (@cristi?), though i see some that should definitively have a preview ready (ie, fashion centre)… We’d need to inspect those requests somehow to figure out why the blue brick is always there
Yes, I have noticed that the urls are estimated on the fly by the web portal but they are not the ones with the preview suffix. If it helps, the code I have used in ue4 is the “Asynch Download Image” blueprint
just to further expand on the url scheme for preview images, you can take any url (stream, commit, branch, or object) and replace the word stream with preview
I confirm that https://speckle.xyz/preview/<YOUR-STREAM-ID>/main
and https://speckle.xyz/preview/<YOUR-STREAM-ID>/
do the same, they get the Stream image.
Also, https://speckle.xyz/preview/<YOUR-STREAM-ID>/commits/<YOUR-COMMIT-ID>
gets the commit image, and https://speckle.xyz/preview/<YOUR-STREAM-ID>/objects/<YOUR-OBJECT-ID>
gets the object succesfully. I haven’t tested the branch, but I guess it should be working.
Also the red cube “Stream is private” is also functioning well for the private streams.
I confirm that adding the headers like this, we can get the private streams in ue4 ! Thanks!