Struct algorithmia::data::DataFile [] [src]

pub struct DataFile { /* fields omitted */ }

Algorithmia data file

Methods

impl DataFile
[src]

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();

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),
};

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]

Get the API Endpoint URL for a particular data URI

Get the Algorithmia data URI a given Data Object Read more

Get the parent off a given Data Object Read more

Get the basename from the Data Object's path (i.e. unix basename) Read more

Determine if a file or directory exists for a particular data URI Read more

impl From<DataObject> for DataFile
[src]

Performs the conversion.