asciinema / agg

asciinema gif generator
https://docs.asciinema.org/manual/agg/
Apache License 2.0
1.21k stars 45 forks source link

Error: application/octet-stream is not supported #82

Open richierg opened 1 month ago

richierg commented 1 month ago

Describe the bug Get error Error: application/octet-stream is not supported when trying to convert url to gif with command like: https://asciinema.mydomain.com/a/MUmPbyFMlDiGTjzT8wVjeClcm output.gif This seems to be related to S3 storage usage.

To Reproduce Steps to reproduce the behavior:

  1. Configure your asciinema server to store data to S3
  2. Upload a cast
  3. Convert the cast from the generated url to GIF with agg
  4. See error

Expected behavior The gif should be generated

Versions:

Additional context I disable S3 storage, and use local one -> works like a charm. So the download from storage on S3 could be a lead.

ku1ik commented 1 month ago

Thanks for the detailed report. I'll try to get to the bottom of it.

hydezhao commented 1 month ago

It works by authorizing application/octet-stream in conditions, but I am not sure if it is the good method.

diff --git a/src/main.rs b/src/main.rs
index 1c6d503..b21e9fa 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -120,7 +120,7 @@ fn download(url: &str) -> Result<impl io::Read> {
         .get(url)
         .header(
             header::ACCEPT,
-            header::HeaderValue::from_static("application/x-asciicast,application/json"),
+            header::HeaderValue::from_static("application/x-asciicast,application/json,application/octet-stream"),
         )
         .build()?;

@@ -132,7 +132,7 @@ fn download(url: &str) -> Result<impl io::Read> {
         .and_then(|hv| hv.to_str().ok())
         .ok_or_else(|| anyhow!("unknown content type".to_owned()))?;

-    if ct != "application/x-asciicast" && ct != "application/json" {
+    if ct != "application/x-asciicast" && ct != "application/json" && ct != "application/octet-stream" {
         return Err(anyhow!(format!("{ct} is not supported")));
     }