Attempt to guess the content type of a file when opening with --raw and set it in the pipeline metadata

This commit is contained in:
Jack Wright 2024-08-02 11:22:47 -07:00
parent 4157ca711d
commit 0f7c9c7f72

View File

@ -146,11 +146,19 @@ impl Command for Open {
}
};
let content_type = if raw {
mime_guess::from_path(path)
.first()
.map(|mime| mime.to_string())
} else {
None
};
let stream = PipelineData::ByteStream(
ByteStream::file(file, call_span, engine_state.signals().clone()),
Some(PipelineMetadata {
data_source: DataSource::FilePath(path.to_path_buf()),
content_type: None,
content_type,
}),
);