use std::path::PathBuf;
use ffsend_api::{
action::upload::Error, action::upload::Upload, api::Version, client::ClientConfigBuilder,
file::remote_file::RemoteFile,
};
use url::Url;
fn main() {
let url = upload_file(PathBuf::from("./README.md"))
.expect("failed to upload file")
.download_url(true);
println!("Share URL: {}", url);
}
fn upload_file(path: PathBuf) -> Result<RemoteFile, Error> {
let client_config = ClientConfigBuilder::default().build().unwrap();
let client = client_config.client(true);
#[cfg(feature = "send3")]
let version = Version::V3;
#[cfg(not(feature = "send3"))]
let version = Version::V2;
let upload = Upload::new(
version,
Url::parse("https://send.firefox.com/").unwrap(),
path,
None,
None,
None,
);
Upload::invoke(upload, &client, None)
}