gossamer/file
Types
A Blob with a filename and last-modified timestamp. Commonly obtained
from file inputs or drag-and-drop.
See File on MDN.
pub type File
pub type FileOption {
Type(String)
LastModified(Int)
}
Constructors
-
Type(String) -
LastModified(Int)
Values
pub fn array_buffer(
of file: File,
) -> promise.Promise(
Result(array_buffer.ArrayBuffer, js_error.JsError),
)
Reads the file’s contents as an ArrayBuffer. Returns an error if
the file cannot be read.
pub fn bytes(
of file: File,
) -> promise.Promise(
Result(uint8_array.Uint8Array, js_error.JsError),
)
Reads the file’s contents as a Uint8Array. Returns an error if the
file cannot be read.
pub fn from_blob_with(
blob: blob.Blob,
named name: String,
with options: List(FileOption),
) -> File
pub fn from_strings(
parts: List(String),
named name: String,
) -> File
pub fn from_strings_with(
parts: List(String),
named name: String,
with options: List(FileOption),
) -> File
pub fn last_modified(of file: File) -> Int
pub fn slice_with_type(
file: File,
from start: Int,
to end: Int,
content_type content_type: String,
) -> blob.Blob
pub fn stream(
of file: File,
) -> readable_stream.ReadableStream(uint8_array.Uint8Array)
pub fn text(
of file: File,
) -> promise.Promise(Result(String, js_error.JsError))
Reads the file’s contents as a UTF-8 string. Returns an error if the file cannot be read.