
I'm just wondering how I should embed videos from Appwrite. I used getFileView and then pass href to src of video tag and I had 401 status code. How I can retrieve video from Appwrite if it secured?

If it's a resource protected by permissions, you will need to specify a JWT token in the request body or you can alternatively use any of the Appwrite SDK

Yes, I already try, it strange that I need additionaly specify JWT for user to retrieve the stream of asset. But I stuck with problem, if I do it protected then I have only one way, retrieve stream and convert it to Blob, then it works as expected.
But when filed like 200MB or even more, I need to await whole asset before user can play it. Very bad UX, and I didn't find any solution to this. I already play around with Buffers, Blobs, but no luck. The MediaSource API from the browser also didn't work for me.

@D5 Also when I embed without protection by direct url for appwrite file, it loads like partially with chunks of data and the video started even if loaded 20MB from 200MB for example.
But with protection I can't perform that, and this is bad somehow. I can't add custom headers to native request (maybe service worker can, but I'm not sure that the video native request can be controlled). And I haven't other ways to perform authorization. 🤨

Hmm that's weird. Seems like a bug

I thought appwrite wasn't able to load the video with chunks and needed to load everything before starting to play

Yep, I already 5 hours try to workaround with that and try everything that I know so far and even not 😆

You know would be great to have some query param like &jwt=<token>

Which will authorize such GET request

Then I guess it will be possible to embed urls where you want

Probably the token is not being specified in URL due to security reasons

But sincerely idk

@D5 thank you for you feedback

@D5 FYI:
self.addEventListener('fetch', event => { const url = new URL(event.request.url); const searchParams = url.searchParams; const jwt = searchParams.get('jwt');
if (jwt) { const request = event.request.clone();
const headers = new Headers(request.headers);
headers.append('X-Appwrite-JWT', jwt);
const modifiedRequest = new Request(request.url, {
method: request.method,
headers: headers,
mode: 'cors',
});
event.respondWith(
fetch(modifiedRequest)
);
} });
self.addEventListener('install', () => { self.skipWaiting(); });
Resolve it with service worker, maybe someone else will face the same problem.

So the logic to have jwt as query param, but under the hood map request with headers instead.

[Resolved] How I can embed video with Appwrite?
Recommended threads
- how many Teams can be created?
I am creating an app where I will let users create groups. This could mean there will be many groups created by user, to isolate those groups properly I am thin...
- React native app login via Safari
Hi! I deployed for debug my React Native app in web, chrome everythink works well but in safari on mac and ios I cant login. I found this one error in safari co...
- Invalid credentials after migration
Hi everyone! After migrating our self-hosted Appwrite 1.3.1 to another server (staging, so a different domain), we are now getting 'Invalid credentials' when ...
