ERT+CONCIERGEAPI| FILE SYSTEM |
|
about protocol gallery previous downloads team ERT | |
ERT CONCIERGE API | FILE SYSTEMThe file system is available to all clients connected to the concierge through the websocket. File transfers are facilitated by regular HTTP requests.All connecting clients are given their own ./fs/client_name/ folder that stores their files. The client folder is deleted when the connecting client disconnects from the server. All HTTP requests to the server must have an Authorization header attached with a uuid value obtained sent from a HELLO websocket payload. Upload Files_ Create a PUT HTTP request to ./fs/client_name/file.extension._ The body should also be an output stream/sink in which the file data gets written to. Upon success/completion of the data stream, the server will return a 201 CREATED status code. Rust ExampleThis is an example of uploading afile using Rust, adapted from the Rust file server client. The rest of the rust examples uselet file = File::open(Path::new(".").join(file_name)).await?; let stream = FramedRead::new(file, BytesCodec::new()); let client = reqwest::Client::new(); let res = client .put(&format!("http://127.0.0.1:8080/fs/{}/{}", name, file_name)) .timeout(Duration::from_secs(1)) .header("Authorization", uuid) .body(Body::wrap_stream(stream)) .send() .await?; Python ExampleCOMING SOON JavaScript ExampleCOMING SOON C#|Unity ExampleCOMING SOON Download Files_ Create GET HTTP request to ./fs/client_name/file.extension._ As long as the authorization UUID is recognized, a 202 ACCEPTED will be returned and a byte stream will be opened. This byte stream can be used to stream data to a local file. Rust Examplelet client = reqwest::Client::new(); let res = client .get(&format!("http://127.0.0.1:8080/fs/{}/{}", name, file_name)) .timeout(Duration::from_secs(1)) .header("Authorization", uuid) .send() .await?; println!("{}", res.status()); let file_path = Path::new(".").join("examples").join("test_download").join(name).join(file_name); tokio::fs::create_dir_all(file_path.parent().unwrap()).await?; let mut file = OpenOptions::new() .create(true) .write(true) .open(file_path) .await?; let mut stream = res.bytes_stream(); // Write the file as the data stream is coming through while let Some(chunk) = stream.next().await { let chunk = chunk?; file.write_all(chunk.bytes()).await?; } file.flush().await?; println!("Done writing!"); Python ExampleCOMING SOON JavaScript ExampleCOMING SOON C#|Unity ExampleCOMING SOON Delete FilesCreate a DELETE HTTP request to ./fs/client_name/file.extension.TheOn success, the server will return a 200 OK status code indicating that the file has been deleted. Rust Examplelet client = reqwest::Client::new(); let res = client .delete(&format!("http://127.0.0.1:8080/fs/{}/{}", name, file_name)) .timeout(Duration::from_secs(1)) .header("Authorization", uuid) .send() .await?; println!("{} {:?}", res.status(), res.text().await); Python ExampleCOMING SOON JavaScript ExampleCOMING SOON C#|Unity ExampleCOMING SOON |
API |
_ project lead : santiago v lombeyda _ surf 2020 | efficient network services & new web base client : an tran _ surf 2019 | network services & python realtime app synchronization : alison noyes _ surf 2019 | network services & matlab large data app communication : sasha fomina _ center director : george djorgovski |
_ team |
PROJECT BORN from CALTECH's OVRAS LAB _ with support from the CENTER for DATA DRIVEN DISCOVERY _ with support from Caltech's SUMMER FELLOWSHIP PROGRAM _ with donations from MICROSOFT _ with donations from LOGITECH _ with donations from NVIDIA _ with donations from HTC |
_ acknowledgements |
ovras | OVS | art by jimBARRY | CD3 | caltech | |