diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 231cbb518e..d538cf0b87 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -1,3 +1,9 @@ += 0.7.0-beta.3 + +== DFX + +=== fix: assets with an unrecognized file extension will use content-type "application/octet-stream" + = 0.7.0-beta.2 == DFX diff --git a/e2e/tests-dfx/assetscanister.bash b/e2e/tests-dfx/assetscanister.bash index eeea4755ad..01032fca04 100644 --- a/e2e/tests-dfx/assetscanister.bash +++ b/e2e/tests-dfx/assetscanister.bash @@ -179,6 +179,7 @@ CHERRIES" "$stdout" touch src/e2e_project_assets/assets/main.css touch src/e2e_project_assets/assets/index.js.map touch src/e2e_project_assets/assets/index.js.LICENSE.txt + touch src/e2e_project_assets/assets/index.js.LICENSE dfx build dfx canister install e2e_project_assets @@ -197,6 +198,8 @@ CHERRIES" "$stdout" assert_match 'content_type = "text/plain"' assert_command dfx canister call --query e2e_project_assets get '(record{key="/index.js.LICENSE.txt";accept_encodings=vec{"identity"}})' assert_match 'content_type = "text/plain"' + assert_command dfx canister call --query e2e_project_assets get '(record{key="/index.js.LICENSE";accept_encodings=vec{"identity"}})' + assert_match 'content_type = "application/octet-stream"' } @test "deletes assets that are removed from project" { diff --git a/src/dfx/src/lib/installers/assets.rs b/src/dfx/src/lib/installers/assets.rs index 62814dbc37..74d90c6bbf 100644 --- a/src/dfx/src/lib/installers/assets.rs +++ b/src/dfx/src/lib/installers/assets.rs @@ -4,7 +4,6 @@ use crate::lib::error::{DfxError, DfxResult}; use crate::lib::waiter::waiter_with_timeout; use candid::{CandidType, Decode, Encode, Nat}; -use anyhow::anyhow; use delay::{Delay, Waiter}; use ic_agent::Agent; use ic_types::Principal; @@ -266,12 +265,7 @@ async fn make_project_asset( let media_type = mime_guess::from_path(&asset_location.source) .first() - .ok_or_else(|| { - anyhow!( - "Unable to determine content type for '{}'.", - asset_location.source.to_string_lossy() - ) - })?; + .unwrap_or(mime::APPLICATION_OCTET_STREAM); let mut encodings = HashMap::new();