|
@@ -1,12 +1,17 @@
|
|
|
extern crate ffsend_api;
|
|
|
+extern crate open;
|
|
|
|
|
|
mod action;
|
|
|
mod app;
|
|
|
mod cmd;
|
|
|
mod util;
|
|
|
|
|
|
+use std::path::Path;
|
|
|
+
|
|
|
use cmd::Handler;
|
|
|
use cmd::cmd_upload::CmdUpload;
|
|
|
+use ffsend_api::action::upload::Upload;
|
|
|
+use ffsend_api::reqwest::Client;
|
|
|
|
|
|
/// Application entrypoint.
|
|
|
fn main() {
|
|
@@ -36,9 +41,18 @@ fn invoke_action(handler: &Handler) {
|
|
|
/// The upload action.
|
|
|
fn action_upload(cmd_upload: &CmdUpload) {
|
|
|
// // Get the path and host
|
|
|
- // let path = Path::new(cmd_upload.file());
|
|
|
- // let host = cmd_upload.host();
|
|
|
+ let path = Path::new(cmd_upload.file()).to_path_buf();
|
|
|
+ let host = cmd_upload.host();
|
|
|
+
|
|
|
+ // Create a reqwest client
|
|
|
+ let client = Client::new();
|
|
|
+
|
|
|
+ // Create an upload action
|
|
|
+ let upload = Upload::new(host, path);
|
|
|
+ let file = upload.invoke(&client).unwrap();
|
|
|
|
|
|
- // // Open the URL in the browser
|
|
|
- // open::that(url).expect("failed to open URL");
|
|
|
+ // Open the URL in the browser
|
|
|
+ let url = file.download_url();
|
|
|
+ println!("Download URL: {}", url);
|
|
|
+ open::that(url).expect("failed to open URL");
|
|
|
}
|