
I actually can weigh in here

I made a function in Node that displays the file preview and webp does seem bugged

I took the Base64 cause I had to due to needing JWT’s in the header for permissions and

It’s def coming back as JPEG for some reason

Lemme get my code

export const $getDocumentPreview = async (fileId: string) => {
const response = storage.getFilePreview(
"655003____4c5735e6",
fileId,
128,
128,
undefined,
undefined,
undefined,
undefined,
8,
undefined,
undefined,
undefined,
"webp"
);
const jwt = await account.createJWT();
const imageResponse = await fetch(response, {
method: "GET",
headers: { "x-appwrite-jwt": jwt.jwt },
});
// Convert the imageResponse to a Blob
const blob = await imageResponse.blob();
// Convert the Blob to a base64 string
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onerror = reject;
reader.onload = () => {
resolve(reader.result);
};
reader.readAsDataURL(blob);
});
};

This is using the node SDK?

That gives me a MIME type of Image/JPEG

Client side

you may need to include the header:
Accept: image/webp

Fair yeah

Why isn't the current users session implemented as permissions or as an optional thing inside the getFilePreview?

Are you not using the SDK client side?

I am

oh yes right sorry

I was thinking node-appwrite

haha

but I set very strict permissions to get as close to PCI compliant as possible, so I set the file permissions on the user level

it would be best to create a separate post for your problem

yeah I did actually

but

unrelated I just wanted to chime in because I saw the webp thing, the headers makes sense,

could be his issue as well

I edited the storage.dart sdk file to contain the accept header, then ran flutter pub get and restarted the app

thanks for the insight
Recommended threads
- How to run queries to get the storage li...
I installed the n8n (self-hosting) and community node n8n-nodes-nappwrite. I tried to get the storage list files more than 25 records. But I cannot find the w...
- Storage video view
Hi! When I want to view a video i uploaded to the storage, it immediaetly starts downloading, so I can't stream it. Is there a way to make it work? I want to al...
- "Memberships privacy" setting in 1.7.4
Hi everyone, I'm experiencing an issue with a clean self-hosted installation of Appwrite version 1.7.4. I previously used version 1.6.1, and if I remember corre...
