https://prefect.io logo
Title
e

Ethienne Marcelin

02/22/2023, 9:43 AM
Hi 😄 I was wondering why we can only write or read bytes on prefect filesystems. Why aren't there any method to write more conventional files like images or videos ?
1
c

Chris Whatley

02/22/2023, 1:48 PM
Those things are also just bytes, so once you have a filesystem object from a storage block (an fsspec object), you can open an output file pointer and use it to write whatever you want. E.g., if you have an image using PIL, you can pass the file pointer to the save() method of the image object. See here: https://filesystem-spec.readthedocs.io/en/latest/usage.html#use-a-file-system
e

Ethienne Marcelin

02/22/2023, 1:56 PM
yeah but not all objects are easily convertible to bytes right ? What if my video has a very specific encoding
c

Chris Whatley

02/22/2023, 1:59 PM
Everything on a computer is represented as bytes one way or another. Just need to figure out the equivalent of the “save” method on whatever library you are using.
👍 1
e

Ethienne Marcelin

02/22/2023, 2:00 PM
yeah that's true Chris 🙂
thanks for your response 💙