File
class File
An interface for working with files on Redivis. When the constructor is called directly, a file_id
must be provided. Also returned by listing files associated with a particular table or query result.
Constructors
query$list_files
([max_results, *, ...])
List files contained within a query result. The query result must contain at least one file_id variable.
redivis$file
(file_id)
Construct a reference to a file based on its globally unique id.
table$list_files
([max_results, *, ...])
List files contained within a file index table. The table must contain at least one file_id variable.
Examples
loadNamespace("redivis")
f = redivis$file("4c10-d8rqhswh8.zz7AB9NJB2ctNpDGKbRD7w")
f$download() # download to current working directory
f$download("new_name.tiff") # download to current working directory, and rename to new_name.tiff
f$download("/some/path/") # downloaded as /some/path/bogota.tiff
f$download("/some/path/new_name.tiff") # downloaded as /some/path/new_name.tiff
print(f$properties)
# $kind
# [1] "rawFile"
# $id
# [1] "4c10-d8rqhswh8.zz7AB9NJB2ctNpDGKbRD7w"
# $uri
# [1] "/rawFiles/4c10-d8rqhswh8.zz7AB9NJB2ctNpDGKbRD7w"
# $name
# [1] "bogota.tiff"
# $contentType
# [1] "image/tiff"
# $md5
# [1] "3Kxlyg=="
# $size
# [1] 253896
Fields
id
The globally unique identifier for the file, as a string.
query
A reference to the query from which this file was loaded from. Will only be populated if constructed via Query.list_files
properties
A dict containing information about the file.
This will be fully populated after calling File.get(), containing the following properties:
id
str
: The globally unique id of the filename
str
: The name of the file, including any extensionssize
int
: The size of the file, in bytescontentType
str
: The MIME type associated with the file's extension, when availablemd5
str
: The md5 checksum of the file, as a base64 string
table
A reference to the table from which this file was loaded from. Will only be populated if constructed via Table.list_files.
Methods
file$download
(path[, ...])
Download the file.
file$get
()
Get file metadata, after which file$properties will be fully populated.
file$read
(as_text[, ...])
Read the file contents into memory, either as raw bytes (the default) or as a string if as_text=True.
file$stream
(callback[, ...])
Read the file in a streaming manner, repeatedly calling the callback function with the latest chunk of bytes.
Last updated
Was this helpful?