Back

PHP sdk file preview is returning characters instead of the url like web sdk

  • 0
  • Self Hosted
  • Web
gaurav_ch
28 Mar, 2024, 12:16

using the following code:

TypeScript
try {
                                    $link = $storage->getFilePreview('profile_photo', $data['profile_photo_id'], 300);
                                    $data['profile_photo_link'] = $link;
                                } catch (AppwriteException $e) {
                                    echo 'error: ' . $e->getMessage();
                                }

I am getting characters when I use the $data['profile_photo_link'] in <img> tag. But in web version of the sdk, I get a URL type and I can use this in an image tag by type casting or using the href property. Is the behaviour different in PHP SDK?

self host v1.4.14

TL;DR
PHP SDK is returning characters instead of a URL for file preview. This behavior is different from the web SDK. The solution is to type cast the returned value to a URL before using it in the image tag.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more