fix: use the pre-fetched mime type (#2417)
This commit is contained in:
@@ -1153,6 +1153,7 @@ impl GoogleDriveRouter {
|
|||||||
async fn get_google_file(
|
async fn get_google_file(
|
||||||
&self,
|
&self,
|
||||||
uri: &str,
|
uri: &str,
|
||||||
|
mime_type: &str,
|
||||||
include_images: bool,
|
include_images: bool,
|
||||||
) -> Result<Vec<Content>, ToolError> {
|
) -> Result<Vec<Content>, ToolError> {
|
||||||
let result = self
|
let result = self
|
||||||
@@ -1171,10 +1172,6 @@ impl GoogleDriveRouter {
|
|||||||
uri, e
|
uri, e
|
||||||
))),
|
))),
|
||||||
Ok(r) => {
|
Ok(r) => {
|
||||||
let file = r.1;
|
|
||||||
let mime_type = file
|
|
||||||
.mime_type
|
|
||||||
.unwrap_or("application/octet-stream".to_string());
|
|
||||||
if mime_type.starts_with("text/") || mime_type == "application/json" {
|
if mime_type.starts_with("text/") || mime_type == "application/json" {
|
||||||
if let Ok(body) = r.0.into_body().collect().await {
|
if let Ok(body) = r.0.into_body().collect().await {
|
||||||
if let Ok(response) = String::from_utf8(body.to_bytes().to_vec()) {
|
if let Ok(response) = String::from_utf8(body.to_bytes().to_vec()) {
|
||||||
@@ -1277,7 +1274,8 @@ impl GoogleDriveRouter {
|
|||||||
self.export_google_file(&drive_uri, &mime_type, include_images)
|
self.export_google_file(&drive_uri, &mime_type, include_images)
|
||||||
.await
|
.await
|
||||||
} else {
|
} else {
|
||||||
self.get_google_file(&drive_uri, include_images).await
|
self.get_google_file(&drive_uri, &mime_type, include_images)
|
||||||
|
.await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user