use sanitzed name
All checks were successful
Build and Publish / build-release (push) Successful in 45s
All checks were successful
Build and Publish / build-release (push) Successful in 45s
This commit is contained in:
@@ -45,14 +45,14 @@ async def upload_document(
|
|||||||
sanitized_filename = utils.sanitize_filename(file.filename)
|
sanitized_filename = utils.sanitize_filename(file.filename)
|
||||||
s3_key = utils.document_s3_key(org_id, document_id, sanitized_filename)
|
s3_key = utils.document_s3_key(org_id, document_id, sanitized_filename)
|
||||||
|
|
||||||
# Prepare metadata
|
# Prepare metadata
|
||||||
metadata_dict = {
|
metadata_dict = {
|
||||||
"org_id": org_id,
|
"org_id": org_id,
|
||||||
"document_type": document_type.value,
|
"document_type": document_type.value,
|
||||||
"filename": file.filename,
|
"filename": sanitized_filename,
|
||||||
"file_size": str(file_size),
|
"file_size": str(file_size),
|
||||||
"created_at": datetime.utcnow().isoformat()
|
"created_at": datetime.utcnow().isoformat()
|
||||||
}
|
}
|
||||||
|
|
||||||
# Upload to S3
|
# Upload to S3
|
||||||
try:
|
try:
|
||||||
@@ -65,18 +65,18 @@ async def upload_document(
|
|||||||
# Generate download URL
|
# Generate download URL
|
||||||
download_url = s3.presigned_download_url(s3_key)
|
download_url = s3.presigned_download_url(s3_key)
|
||||||
|
|
||||||
# Create metadata response
|
# Create metadata response
|
||||||
metadata = DocumentMetadata(
|
metadata = DocumentMetadata(
|
||||||
document_id=document_id,
|
document_id=document_id,
|
||||||
org_id=org_id,
|
org_id=org_id,
|
||||||
document_type=document_type,
|
document_type=document_type,
|
||||||
filename=file.filename,
|
filename=sanitized_filename,
|
||||||
content_type=detected_content_type,
|
content_type=detected_content_type,
|
||||||
file_size=file_size,
|
file_size=file_size,
|
||||||
s3_key=s3_key,
|
s3_key=s3_key,
|
||||||
created_at=datetime.utcnow(),
|
created_at=datetime.utcnow(),
|
||||||
updated_at=datetime.utcnow()
|
updated_at=datetime.utcnow()
|
||||||
)
|
)
|
||||||
|
|
||||||
logger.info(f"Upload completed - document_id: {document_id}")
|
logger.info(f"Upload completed - document_id: {document_id}")
|
||||||
return UploadResponse(document_id=document_id, metadata=metadata, download_url=download_url)
|
return UploadResponse(document_id=document_id, metadata=metadata, download_url=download_url)
|
||||||
|
|||||||
Reference in New Issue
Block a user