Skip to content

Commit

Permalink
Fix mimetype parsing for ValueError: not enough values to unpack (exp…
Browse files Browse the repository at this point in the history
…ected 2, got 1)
  • Loading branch information
KastanDay committed Mar 12, 2024
1 parent 3abc7eb commit 107eef5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ai_ta_backend/beam/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import uuid
from pathlib import Path
from tempfile import NamedTemporaryFile
from typing import Any, Callable, Dict, List, Union
from typing import Any, Callable, Dict, List, Optional, Union

import beam
import boto3
Expand Down Expand Up @@ -245,7 +245,7 @@ def _ingest_single(ingest_method: Callable, s3_path, *args, **kwargs):
with NamedTemporaryFile(suffix=file_extension) as tmpfile:
self.s3_client.download_fileobj(Bucket=os.environ['S3_BUCKET_NAME'], Key=s3_path, Fileobj=tmpfile)
mime_type = str(mimetypes.guess_type(tmpfile.name, strict=False)[0])
mime_category, mime_subcategory = mime_type.split('/')
mime_category = mime_type.split('/')[0] if '/' in mime_type else mime_type

if file_extension in file_ingest_methods:
# Use specialized functions when possible, fallback to mimetype. Else raise error.
Expand Down

0 comments on commit 107eef5

Please sign in to comment.