denizparlak1 / learning-platform

1 stars 0 forks source link

S3 Implementation #20

Open denizparlak1 opened 1 month ago

denizparlak1 commented 1 month ago

Create repository, service, api, connection, config, key, and JSON for GCS integration.

denizparlak1 commented 4 weeks ago

S3 service implementation completed.

`class S3Service: def init(self, config: S3Config): self.client = boto3.client( 's3', aws_access_key_id=config.aws_access_key_id, aws_secret_access_key=config.aws_secret_access_key, region_name=config.region_name ) self.bucket_name = config.bucket_name

def upload_file(self, file_path, file_content, content_type=None):
    try:
        response = self.client.upload_fileobj(
            io.BytesIO(file_content),
            self.bucket_name,
            file_path,
            ExtraArgs={"ContentType": content_type}
        )
        return file_path
    except Exception as e:
        raise Exception(f"S3 Error: {e}")

def get_s3_service(config: S3Config = Depends(get_s3_config)) -> S3Service: return S3Service(config) `