# app/services/upload_service.py import boto3 from botocore.exceptions import NoCredentialsError class UploadService: def __init__(self, bucket_name): self.s3_client = boto3.client('s3') self.bucket_name = bucket_name def upload_file(self, file, file_name): try: self.s3_client.upload_fileobj(file, self.bucket_name, file_name) return f"https://{self.bucket_name}.s3.amazonaws.com/{file_name}" except NoCredentialsError: raise Exception("AWS credentials not found") except Exception as e: raise e