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:
parent
4157ca711d
commit
0f7c9c7f72
|
@ -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(
|
let stream = PipelineData::ByteStream(
|
||||||
ByteStream::file(file, call_span, engine_state.signals().clone()),
|
ByteStream::file(file, call_span, engine_state.signals().clone()),
|
||||||
Some(PipelineMetadata {
|
Some(PipelineMetadata {
|
||||||
data_source: DataSource::FilePath(path.to_path_buf()),
|
data_source: DataSource::FilePath(path.to_path_buf()),
|
||||||
content_type: None,
|
content_type,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user