Back

[SOLVED] How to determine if the file from a bucket is either a photo or a video?

  • 0
  • General
  • Web
  • Storage
kathelia.dokgu
26 Aug, 2023, 22:14

I have a file ID and I only want to call the getFilePreview() if the file is a photo. If it's a video file, I'll handle it differently and won't bother getting a preview image and simply show a video tag.

TL;DR
The user wants to determine if a file from a bucket is a photo or a video. The solution is to use the `getFile` function which returns a file object with a `mimeType` property. If the mimeType is a photo, call `getFilePreview()`, otherwise handle it differently for video files.
Guille
26 Aug, 2023, 22:20
kathelia.dokgu
26 Aug, 2023, 22:22

I see, thank you!

Guille
26 Aug, 2023, 22:23

[SOLVED] How to determine if the file from a bucket is either a photo or a video?

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