Skip to main content
Vane Data / Reference

File constructors

Constructors build FILE-family expressions. By default, file, image_file, audio_file, and video_file do not access the referenced object; to_file, try_to_file, and from_files resolve storage when executed.

Signature

example.py
vane.file(url, content_type=None, position=None, size=None, checksum=None) -> Expression
vane.image_file(url_or_file, verify=False) -> Expression
vane.audio_file(url_or_file, verify=False) -> Expression
vane.video_file(url_or_file, verify=False) -> Expression
vane.to_file(path) -> Expression
vane.try_to_file(path) -> Expression
vane.from_files(path, *, connection=None) -> Relation

SQL: file(url, content_type, position, size, checksum), image_file(url_or_file [, verify]), audio_file(url_or_file [, verify]), video_file(url_or_file [, verify]), to_file(path), and try_to_file(path). In SQL, file requires all five arguments; the Python form defaults the optional fields to None. from_files is Python-only.

expr.as_file(media_type=MediaType.unknown()) is the Expression method form: it builds the same FILE-family expression from the expression's string value, with media_type selecting FILE, IMAGEFILE, AUDIOFILE, or VIDEOFILE.

Parameters

NameTypeDescriptionDefault
urlString or ExpressionObject URLRequired
content_typeString, Expression, or NoneDeclared MIME typeNone
position / sizeInteger, Expression, or NoneOptional byte window into the objectNone
checksumString, Expression, or NoneDeclared checksumNone
url_or_fileString, FILE value, or ExpressionURL or FILE view to re-type as IMAGEFILE/AUDIOFILE/VIDEOFILERequired
verifybool or ExpressionVerify bounded content when constructing the valueFalse
pathString, Expression, or list of strings (from_files)Path(s) resolved to FILERequired

Returns and errors

file, to_file, and try_to_file return FILE; image_file/audio_file/video_file return the matching typed FILE. to_file and try_to_file open the object at execution and return its complete logical view (position = 0, size = object size); to_file raises on failure, while try_to_file returns NULL for recoverable access failures. from_files returns a one-column relation of canonical FILE values, built on list_files. file never accesses the object; the typed constructors access it only when verify=True performs a bounded content check.

Example

example.py
import vane


con = vane.connect()
con.sql("SELECT image_file('photo.png') AS file").show()
vane.from_files("photos/*.png", connection=con).show()