Back

[SOLVED] Web SDK storage creates with second fetch messupd URLs

  • 0
  • Web
WuGGu
29 Oct, 2023, 17:52

Hi all,

I use NuxtJS 3 with the Web SDK and a self hosted Appwrite backend. I have a dropdown select which lets me switch between video files. But if I call a video a second time I get a messedup URL.

https://backend.example.com/v1/storage/buckets/111122233334444/files/555666777/view?project=8889990000

https://backend.example.com/v1/storage/buckets/111122233334444/files/https://backend.plezier.de/v1/storage/buckets/111122233334444/files/555666777/view?project=8889990000%2Fview&project=8889990000

I use the SDK in a composable to generate similar returns:

TypeScript
  const getPreviewUrlVideo = async (fileid: string) => {
    const { storage } = useAppwrite();
    try {
      const res = await storage.getFileView(VIDEO_BUCKET, fileid);
      return { success: true, data: res, error: null };
    } catch (err) {
      if (err instanceof AppwriteException) {
        return {
          success: false,
          data: null,
          error: err.message,
        };
      } else {
        return {
          success: false,
          data: null,
          error: "Unkown Error",
        };
      }
    }
  };

I used the VS Code Debugger and the URL is coming this way out of the SDK function. Is this a Bug? Should I report it on GitHub?

TL;DR
The user was experiencing an issue with the Web SDK storage, where calling a video file for the second time resulted in a messed up URL. However, the issue was solved with a single question. The problem occurred because the `fieldid` property was being overwritten with the URL, and the page needed to be reloaded for the change to take effect. The user expressed gratitude to the person who guided them in the right direction. It is unclear if the issue needs to be reported on GitHub.
Drake
29 Oct, 2023, 18:49

What's being passed in as the file id the second time?

WuGGu
29 Oct, 2023, 18:52

You solved the problem with just one question. I don’t have to look into the code to now that the url is on the field of the fieldid because I overwrite the fieldid property with the url and if I don’t reload the page it does not change. Thanks a lot @Steven for pushing me in the right direction 🥰

Drake
29 Oct, 2023, 18:52

[SOLVED] Web SDK storage creates with second fetch messupd URLs

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