Struct algorithmia::data::DataFile
[−]
[src]
pub struct DataFile { /* fields omitted */ }
Algorithmia data file
Methods
impl DataFile
[src]
fn put<B>(&self, body: B) -> Result<()> where
B: Into<Body>,
B: Into<Body>,
Write to the Algorithmia Data API
Examples
let client = Algorithmia::client("111112222233333444445555566"); client.file(".my/my_dir/string.txt").put("file_contents").unwrap(); client.file(".my/my_dir/bytes.txt").put("file_contents".as_bytes()).unwrap(); let file = File::open("/path/to/file.jpg").unwrap(); client.file(".my/my_dir/file.jpg").put(file).unwrap();
fn get(&self) -> Result<FileData>
Get a file from the Algorithmia Data API
Examples
let client = Algorithmia::client("111112222233333444445555566"); let my_file = client.file(".my/my_dir/sample.txt"); match my_file.get() { Ok(mut response) => { let mut data = String::new(); match response.read_to_string(&mut data) { Ok(_) => println!("{}", data), Err(err) => println!("IOError: {}", err), } }, Err(err) => println!("Error downloading file: {}", err), };
fn delete(&self) -> Result<()>
Delete a file from from the Algorithmia Data API
Examples
let client = Algorithmia::client("111112222233333444445555566"); let my_file = client.file(".my/my_dir/sample.txt"); match my_file.delete() { Ok(_) => println!("Successfully deleted file"), Err(err) => println!("Error deleting file: {}", err), };
Trait Implementations
impl HasDataPath for DataFile
[src]
fn to_url(&self) -> Result<Url>
Get the API Endpoint URL for a particular data URI
fn to_data_uri(&self) -> String
Get the Algorithmia data URI a given Data Object Read more
fn parent(&self) -> Option<DataDir>
Get the parent off a given Data Object Read more
fn basename(&self) -> Option<String>
Get the basename from the Data Object's path (i.e. unix basename
) Read more
fn exists(&self) -> Result<bool>
Determine if a file or directory exists for a particular data URI Read more
impl From<DataObject> for DataFile
[src]
fn from(d: DataObject) -> Self
Performs the conversion.