patharanor commited on
Commit
3b02982
·
1 Parent(s): a25c7ca

fix: parse metadata

Browse files
Files changed (2) hide show
  1. apis/s3.py +3 -1
  2. app.py +1 -2
apis/s3.py CHANGED
@@ -35,7 +35,6 @@ class S3:
35
 
36
  # Function to upload file to S3
37
  def upload_file(self, bucket_name, file, name, metadata:dict):
38
- logging.info(f'Current metadata: {json.dumps(metadata)}')
39
  res = Response()
40
  try:
41
  # self.client.upload_fileobj(
@@ -47,6 +46,9 @@ class S3:
47
  # 'x-request-id': req_id,
48
  # }
49
  # })
 
 
 
50
  self.client.put_object(
51
  Body=file,
52
  Bucket=bucket_name,
 
35
 
36
  # Function to upload file to S3
37
  def upload_file(self, bucket_name, file, name, metadata:dict):
 
38
  res = Response()
39
  try:
40
  # self.client.upload_fileobj(
 
46
  # 'x-request-id': req_id,
47
  # }
48
  # })
49
+
50
+ metadata = {k: str(v) for k, v in metadata.items()}
51
+
52
  self.client.put_object(
53
  Body=file,
54
  Bucket=bucket_name,
app.py CHANGED
@@ -80,8 +80,7 @@ async def upload(
80
  logging.info(f'Key for S3 upload: {key}')
81
  if o.content is not None:
82
  try:
83
- metadata: Dict[str, Any] = json.loads(metadata)
84
- logging.info(metadata)
85
  except Exception as e:
86
  metadata = {}
87
  logging.info(f'Error: {str(e)}\nUse default metadata instead.')
 
80
  logging.info(f'Key for S3 upload: {key}')
81
  if o.content is not None:
82
  try:
83
+ metadata = json.loads(metadata)
 
84
  except Exception as e:
85
  metadata = {}
86
  logging.info(f'Error: {str(e)}\nUse default metadata instead.')