content_type -> mime_type
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
-- Revert column rename.
|
||||||
|
ALTER TABLE tenant.documents
|
||||||
|
RENAME COLUMN mime_type TO content_type;
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
-- Rename document content_type column to mime_type for consistency with API.
|
||||||
|
ALTER TABLE tenant.documents
|
||||||
|
RENAME COLUMN content_type TO mime_type;
|
||||||
@@ -540,7 +540,7 @@ pub struct Document {
|
|||||||
pub id: Uuid,
|
pub id: Uuid,
|
||||||
pub filename: String,
|
pub filename: String,
|
||||||
pub original_name: String,
|
pub original_name: String,
|
||||||
pub content_type: Option<String>,
|
pub mime_type: Option<String>,
|
||||||
pub folder_id: Option<Uuid>,
|
pub folder_id: Option<Uuid>,
|
||||||
pub created_at: NaiveDateTime,
|
pub created_at: NaiveDateTime,
|
||||||
pub updated_at: NaiveDateTime,
|
pub updated_at: NaiveDateTime,
|
||||||
@@ -558,7 +558,7 @@ pub struct NewDocument {
|
|||||||
pub id: Uuid,
|
pub id: Uuid,
|
||||||
pub filename: String,
|
pub filename: String,
|
||||||
pub original_name: String,
|
pub original_name: String,
|
||||||
pub content_type: Option<String>,
|
pub mime_type: Option<String>,
|
||||||
pub folder_id: Option<Uuid>,
|
pub folder_id: Option<Uuid>,
|
||||||
pub current_version_id: Uuid,
|
pub current_version_id: Uuid,
|
||||||
pub metadata: serde_json::Value,
|
pub metadata: serde_json::Value,
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ pub async fn upload_document(
|
|||||||
let user_id = user_id;
|
let user_id = user_id;
|
||||||
let mut file_bytes: Option<Vec<u8>> = None;
|
let mut file_bytes: Option<Vec<u8>> = None;
|
||||||
let mut original_name: Option<String> = None;
|
let mut original_name: Option<String> = None;
|
||||||
let mut content_type: Option<String> = None;
|
let mut mime_type: Option<String> = None;
|
||||||
let mut folder_id: Option<Uuid> = None;
|
let mut folder_id: Option<Uuid> = None;
|
||||||
let mut metadata: Value = Value::Object(Default::default());
|
let mut metadata: Value = Value::Object(Default::default());
|
||||||
let mut tag_ids: Vec<Uuid> = Vec::new();
|
let mut tag_ids: Vec<Uuid> = Vec::new();
|
||||||
@@ -219,7 +219,7 @@ pub async fn upload_document(
|
|||||||
Some("file") => {
|
Some("file") => {
|
||||||
let file_name = field.file_name().map(|n| n.to_string());
|
let file_name = field.file_name().map(|n| n.to_string());
|
||||||
original_name = file_name.clone();
|
original_name = file_name.clone();
|
||||||
content_type = field.content_type().map(|mime| mime.to_string());
|
mime_type = field.content_type().map(|mime| mime.to_string());
|
||||||
let data = field.bytes().await.map_err(|err| {
|
let data = field.bytes().await.map_err(|err| {
|
||||||
let msg = format!("failed to read file bytes: {err}");
|
let msg = format!("failed to read file bytes: {err}");
|
||||||
error!(error = %err, "failed to read file bytes");
|
error!(error = %err, "failed to read file bytes");
|
||||||
@@ -348,7 +348,7 @@ pub async fn upload_document(
|
|||||||
let request = DocumentUploadRequest {
|
let request = DocumentUploadRequest {
|
||||||
bytes: file_bytes,
|
bytes: file_bytes,
|
||||||
original_name,
|
original_name,
|
||||||
content_type,
|
mime_type,
|
||||||
folder_id,
|
folder_id,
|
||||||
metadata,
|
metadata,
|
||||||
title_override,
|
title_override,
|
||||||
@@ -689,7 +689,7 @@ pub async fn download_with_token(
|
|||||||
&version.s3_key,
|
&version.s3_key,
|
||||||
disposition.as_deref(),
|
disposition.as_deref(),
|
||||||
headers.get(header::RANGE).cloned(),
|
headers.get(header::RANGE).cloned(),
|
||||||
doc.content_type.as_deref(),
|
doc.mime_type.as_deref(),
|
||||||
Some(version.id.to_string()),
|
Some(version.id.to_string()),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|||||||
@@ -351,7 +351,7 @@ async fn stream_document(
|
|||||||
|
|
||||||
if let Some(content_type) = upstream.headers().get(header::CONTENT_TYPE) {
|
if let Some(content_type) = upstream.headers().get(header::CONTENT_TYPE) {
|
||||||
builder = builder.header(header::CONTENT_TYPE, content_type);
|
builder = builder.header(header::CONTENT_TYPE, content_type);
|
||||||
} else if let Some(ref typ) = document.content_type {
|
} else if let Some(ref typ) = document.mime_type {
|
||||||
builder = builder.header(header::CONTENT_TYPE, typ);
|
builder = builder.header(header::CONTENT_TYPE, typ);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -529,7 +529,7 @@ fn build_resources_for_folder(
|
|||||||
display_name,
|
display_name,
|
||||||
is_collection: true,
|
is_collection: true,
|
||||||
content_length: None,
|
content_length: None,
|
||||||
content_type: None,
|
mime_type: None,
|
||||||
last_modified,
|
last_modified,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -545,7 +545,7 @@ fn build_resources_for_folder(
|
|||||||
display_name: subfolder.name.clone(),
|
display_name: subfolder.name.clone(),
|
||||||
is_collection: true,
|
is_collection: true,
|
||||||
content_length: None,
|
content_length: None,
|
||||||
content_type: None,
|
mime_type: None,
|
||||||
last_modified: Some(to_http_date(subfolder.updated_at)),
|
last_modified: Some(to_http_date(subfolder.updated_at)),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -583,7 +583,7 @@ fn document_to_resource(
|
|||||||
display_name: document.title.clone(),
|
display_name: document.title.clone(),
|
||||||
is_collection: false,
|
is_collection: false,
|
||||||
content_length: Some(version.size_bytes),
|
content_length: Some(version.size_bytes),
|
||||||
content_type: document.content_type.clone(),
|
mime_type: document.mime_type.clone(),
|
||||||
last_modified: Some(to_http_date(document.updated_at)),
|
last_modified: Some(to_http_date(document.updated_at)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -639,7 +639,7 @@ fn render_multistatus(resources: &[DavResource]) -> Result<Vec<u8>, quick_xml::E
|
|||||||
writer.write_event(Event::End(BytesEnd::new("D:getcontentlength")))?;
|
writer.write_event(Event::End(BytesEnd::new("D:getcontentlength")))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(content_type) = &resource.content_type {
|
if let Some(content_type) = &resource.mime_type {
|
||||||
writer.write_event(Event::Start(BytesStart::new("D:getcontenttype")))?;
|
writer.write_event(Event::Start(BytesStart::new("D:getcontenttype")))?;
|
||||||
writer.write_event(Event::Text(BytesText::new(content_type)))?;
|
writer.write_event(Event::Text(BytesText::new(content_type)))?;
|
||||||
writer.write_event(Event::End(BytesEnd::new("D:getcontenttype")))?;
|
writer.write_event(Event::End(BytesEnd::new("D:getcontenttype")))?;
|
||||||
@@ -681,7 +681,7 @@ struct DavResource {
|
|||||||
display_name: String,
|
display_name: String,
|
||||||
is_collection: bool,
|
is_collection: bool,
|
||||||
content_length: Option<i64>,
|
content_length: Option<i64>,
|
||||||
content_type: Option<String>,
|
mime_type: Option<String>,
|
||||||
last_modified: Option<String>,
|
last_modified: Option<String>,
|
||||||
}
|
}
|
||||||
enum ResolvedPath {
|
enum ResolvedPath {
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ diesel::table! {
|
|||||||
#[max_length = 255]
|
#[max_length = 255]
|
||||||
original_name -> Varchar,
|
original_name -> Varchar,
|
||||||
#[max_length = 100]
|
#[max_length = 100]
|
||||||
content_type -> Nullable<Varchar>,
|
mime_type -> Nullable<Varchar>,
|
||||||
folder_id -> Nullable<Uuid>,
|
folder_id -> Nullable<Uuid>,
|
||||||
created_at -> Timestamptz,
|
created_at -> Timestamptz,
|
||||||
updated_at -> Timestamptz,
|
updated_at -> Timestamptz,
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ pub struct DocumentResponse {
|
|||||||
pub title: String,
|
pub title: String,
|
||||||
pub original_name: String,
|
pub original_name: String,
|
||||||
#[schema(nullable)]
|
#[schema(nullable)]
|
||||||
pub content_type: Option<String>,
|
pub mime_type: Option<String>,
|
||||||
#[schema(nullable)]
|
#[schema(nullable)]
|
||||||
pub folder_id: Option<Uuid>,
|
pub folder_id: Option<Uuid>,
|
||||||
pub created_at: String,
|
pub created_at: String,
|
||||||
@@ -225,7 +225,7 @@ fn default_true() -> bool {
|
|||||||
pub struct DocumentUploadRequest {
|
pub struct DocumentUploadRequest {
|
||||||
pub bytes: Vec<u8>,
|
pub bytes: Vec<u8>,
|
||||||
pub original_name: String,
|
pub original_name: String,
|
||||||
pub content_type: Option<String>,
|
pub mime_type: Option<String>,
|
||||||
pub folder_id: Option<Uuid>,
|
pub folder_id: Option<Uuid>,
|
||||||
pub metadata: Value,
|
pub metadata: Value,
|
||||||
pub title_override: Option<String>,
|
pub title_override: Option<String>,
|
||||||
@@ -685,7 +685,7 @@ impl<'a> DocumentsService<'a> {
|
|||||||
let DocumentUploadRequest {
|
let DocumentUploadRequest {
|
||||||
bytes,
|
bytes,
|
||||||
original_name,
|
original_name,
|
||||||
content_type,
|
mime_type,
|
||||||
folder_id,
|
folder_id,
|
||||||
metadata,
|
metadata,
|
||||||
title_override,
|
title_override,
|
||||||
@@ -739,7 +739,7 @@ impl<'a> DocumentsService<'a> {
|
|||||||
.put_object(
|
.put_object(
|
||||||
&s3_key,
|
&s3_key,
|
||||||
bytes.clone(),
|
bytes.clone(),
|
||||||
content_type.clone(),
|
mime_type.clone(),
|
||||||
content_disposition.clone(),
|
content_disposition.clone(),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
@@ -756,7 +756,7 @@ impl<'a> DocumentsService<'a> {
|
|||||||
id: doc_id,
|
id: doc_id,
|
||||||
filename: stored_filename.clone(),
|
filename: stored_filename.clone(),
|
||||||
original_name: original_name.clone(),
|
original_name: original_name.clone(),
|
||||||
content_type: content_type.clone(),
|
mime_type: mime_type.clone(),
|
||||||
folder_id,
|
folder_id,
|
||||||
current_version_id: version_id,
|
current_version_id: version_id,
|
||||||
metadata: metadata_value.clone(),
|
metadata: metadata_value.clone(),
|
||||||
@@ -1418,7 +1418,7 @@ impl<'a> DocumentsService<'a> {
|
|||||||
filename: doc.filename,
|
filename: doc.filename,
|
||||||
title: doc.title,
|
title: doc.title,
|
||||||
original_name: doc.original_name,
|
original_name: doc.original_name,
|
||||||
content_type: doc.content_type,
|
mime_type: doc.mime_type,
|
||||||
folder_id: doc.folder_id,
|
folder_id: doc.folder_id,
|
||||||
created_at: to_iso(doc.created_at),
|
created_at: to_iso(doc.created_at),
|
||||||
updated_at: to_iso(doc.updated_at),
|
updated_at: to_iso(doc.updated_at),
|
||||||
|
|||||||
@@ -155,8 +155,8 @@ pub(crate) fn determine_thumbnail_support(document: &Document) -> (bool, Option<
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
if let Some(ref content_type) = document.content_type {
|
if let Some(ref mime_type) = document.mime_type {
|
||||||
if supported_mimes.contains(content_type.as_str()) {
|
if supported_mimes.contains(mime_type.as_str()) {
|
||||||
return (true, None);
|
return (true, None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,7 +183,7 @@ pub(crate) fn determine_thumbnail_support(document: &Document) -> (bool, Option<
|
|||||||
|
|
||||||
fn document_supports_ocr(document: &Document) -> bool {
|
fn document_supports_ocr(document: &Document) -> bool {
|
||||||
document
|
document
|
||||||
.content_type
|
.mime_type
|
||||||
.as_deref()
|
.as_deref()
|
||||||
.map(|mime| mime.eq_ignore_ascii_case("application/pdf"))
|
.map(|mime| mime.eq_ignore_ascii_case("application/pdf"))
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ impl Task<DocumentVersionTaskContext> for GenerateOcrTask {
|
|||||||
|
|
||||||
let bytes = ctx.buffered_object().await?.to_vec();
|
let bytes = ctx.buffered_object().await?.to_vec();
|
||||||
let meta = PdfDocumentMeta {
|
let meta = PdfDocumentMeta {
|
||||||
content_type: context.document.content_type.clone(),
|
mime_type: context.document.mime_type.clone(),
|
||||||
original_name: context.document.original_name.clone(),
|
original_name: context.document.original_name.clone(),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -284,7 +284,7 @@ fn generate_ocr_text(meta: &PdfDocumentMeta, bytes: &[u8]) -> Option<OcrGenerati
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct PdfDocumentMeta {
|
struct PdfDocumentMeta {
|
||||||
content_type: Option<String>,
|
mime_type: Option<String>,
|
||||||
original_name: String,
|
original_name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -395,8 +395,8 @@ fn run_ocr(bytes: &[u8]) -> Result<Option<String>, OcrError> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn document_meta_is_pdf(meta: &PdfDocumentMeta) -> bool {
|
fn document_meta_is_pdf(meta: &PdfDocumentMeta) -> bool {
|
||||||
if let Some(content_type) = &meta.content_type {
|
if let Some(mime_type) = &meta.mime_type {
|
||||||
if content_type.eq_ignore_ascii_case("application/pdf") {
|
if mime_type.eq_ignore_ascii_case("application/pdf") {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -410,7 +410,7 @@ fn document_meta_is_pdf(meta: &PdfDocumentMeta) -> bool {
|
|||||||
|
|
||||||
fn document_is_pdf(document: &Document) -> bool {
|
fn document_is_pdf(document: &Document) -> bool {
|
||||||
document
|
document
|
||||||
.content_type
|
.mime_type
|
||||||
.as_deref()
|
.as_deref()
|
||||||
.map(|mime| mime.eq_ignore_ascii_case("application/pdf"))
|
.map(|mime| mime.eq_ignore_ascii_case("application/pdf"))
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
|
|||||||
@@ -463,7 +463,7 @@ fn persist_document_page_count(
|
|||||||
|
|
||||||
fn document_is_pdf(document: &Document) -> bool {
|
fn document_is_pdf(document: &Document) -> bool {
|
||||||
document
|
document
|
||||||
.content_type
|
.mime_type
|
||||||
.as_deref()
|
.as_deref()
|
||||||
.map(|mime| mime.eq_ignore_ascii_case("application/pdf"))
|
.map(|mime| mime.eq_ignore_ascii_case("application/pdf"))
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
|
|||||||
Reference in New Issue
Block a user