From c7f240701089df17306dfd7d3816129f372e5a6c Mon Sep 17 00:00:00 2001 From: softprops Date: Sun, 25 Aug 2019 23:33:39 -0400 Subject: [PATCH] assets need names --- src/github.rs | 6 ++++-- src/main.rs | 13 +++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/github.rs b/src/github.rs index 10764e5..18e2612 100644 --- a/src/github.rs +++ b/src/github.rs @@ -35,6 +35,7 @@ pub trait AssetUploader = File> { github_token: &str, github_repo: &str, release_id: usize, + name: &str, mime: Mime, asset: A, ) -> Result>; @@ -85,13 +86,14 @@ impl> AssetUploader for Client { github_token: &str, github_repo: &str, release_id: usize, + name: &str, mime: mime::Mime, asset: A, ) -> Result> { Ok(self .post(&format!( - "http://uploads.github.com/repos/{}/releases/{}/assets", - github_repo, release_id + "http://uploads.github.com/repos/{}/releases/{}/assets?name={}", + github_repo, release_id, name )) .header("Authorization", format!("bearer {}", github_token)) .header("Content-Type", mime.to_string()) diff --git a/src/main.rs b/src/main.rs index ec2196c..6dc2b47 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,6 +6,7 @@ use reqwest::Client; use serde::Deserialize; use std::{ error::Error, + ffi::OsStr, fs::File, path::{Path, PathBuf}, }; @@ -95,17 +96,17 @@ fn run( if let Some(patterns) = conf.input_files { for path in paths(patterns)? { - println!( - "⬆️ Uploading {} asset {}", - mime_or_default(&path), - path.display() - ); + println!("⬆️ Uploading asset {}", path.display()); let status = uploader.upload( conf.github_token.as_str(), conf.github_repository.as_str(), id, + &path + .file_name() + .and_then(OsStr::to_str) + .unwrap_or_else(|| "Unknown file"), mime_or_default(&path), - File::open(path)?, + File::open(&path)?, )?; println!("uploaded with status {}", status); }