vkumartr commited on
Commit
d328ab2
·
verified ·
1 Parent(s): 38d0aae

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -0
app.py CHANGED
@@ -239,6 +239,15 @@ def verify_api_key(api_key: str = Header(...)):
239
  def read_root():
240
  return {"message": "Welcome to the Invoice Summarization API!"}
241
 
 
 
 
 
 
 
 
 
 
242
  @app.get("/ocr/extraction")
243
  def extract_text_from_file(
244
  api_key: str = Depends(verify_api_key),
 
239
  def read_root():
240
  return {"message": "Welcome to the Invoice Summarization API!"}
241
 
242
+ def get_content_type_from_s3(file_key):
243
+ """Fetch the content type (MIME type) of a file stored in S3."""
244
+ try:
245
+ response = s3_client.head_object(Bucket=S3_BUCKET_NAME, Key=file_key)
246
+ return response.get('ContentType', 'application/octet-stream') # Default to binary if not found
247
+ except Exception as e:
248
+ raise Exception(f"Failed to get content type from S3: {str(e)}")
249
+
250
+
251
  @app.get("/ocr/extraction")
252
  def extract_text_from_file(
253
  api_key: str = Depends(verify_api_key),