-
-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
Hello,
I am working on a "toy" send client. I have some code which uses the ffsend_api to create and invoke an Upload struct. For some reason, when I try to set the expiry parameter to something over 3 days, I get Error::UploadError(InvalidResponse) from the server. I'm not sure if this is default, expect behavior, but just thought I'd ask!
Also, but why not use the built-in std::time::duration structs for the expiry? Just a thought. 😅
Code snippet:
#[derive(Args)]
pub struct UploadArgs {
/// Path to the file to upload
pub file: String,
}
pub fn upload_file_cmd(args: UploadArgs) {
let path = PathBuf::from(args.file);
match upload_file(path) {
Ok(remote_file) => {
let share_url = remote_file.download_url(true);
println!("Share URL: {}", share_url);
}
Err(Error::Upload(e)) => {
eprintln!("Failed to upload file: {}", e);
}
Err(e) => {
eprintln!("Some other error occurred: {:?}", e);
}
}
}
fn upload_file(path: PathBuf) -> Result<RemoteFile, Error> {
let client_config = ClientConfigBuilder::default()
.build()
.expect("Failed to build client config");
let client = client_config.client(true);
let version = Version::V3;
// expiry time is in seconds, 604800 = 7 days
// The following code is what is used in ffsend itself for it's upload command.
// Seems like best practice, hence why I changed it
let params = {
let params = ParamsDataBuilder::default()
.download_limit(Some(5))
// TODO: Debug why expiry time is causing issues
.expiry_time(Some(259_800))
.build()
.unwrap();
if params.is_empty() {
None
} else {
Some(params)
}
};
let upload = Upload::new(
version,
Url::parse("https://send.vis.ee/").expect("Invalid URL"),
path,
None,
None,
params,
);
Upload::invoke(upload, &client, None)
}Link to repo if more context is required: https://github.com/BYTE-Club-CCNY/Cryo/tree/main
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels