Skip to content

CR0010: Update FastApi to support S3 upload #3

Description

@tenkus47

1. Description

This RFC proposes an enhancement to the existing FastAPI service to enable file uploads directly to an Amazon S3 bucket. The implementation will include generating pre-signed URLs for S3 uploads, ensuring security and scalability, and integrating with the AWS SDK. The goal is to allow users to upload files securely via the FastAPI service without handling file storage in the application itself.

2. Completion Criteria

  • FastAPI endpoint that generates pre-signed URLs for S3 uploads.
  • Users can securely upload files to S3 using the generated pre-signed URLs.
  • Proper error handling for failed uploads or invalid URLs.
  • Unit and integration tests to validate functionality.
  • Documentation outlining how to use the S3 upload feature.

3. Implementation Plan

  1. S3 Bucket Setup

    • Set up an S3 bucket with proper IAM policies to restrict access and allow uploads using pre-signed URLs.
  2. Integrate AWS SDK

    • Add the AWS SDK to the FastAPI project for generating pre-signed URLs.
  3. FastAPI Endpoint

    • Create a new FastAPI route that generates a pre-signed URL when requested. This URL will be used by clients to upload files directly to S3.
  4. Security Considerations

    • Use environment variables to manage AWS credentials.
    • Ensure the generated pre-signed URLs have an expiration time.
  5. Error Handling

    • Handle cases where the pre-signed URL generation fails.
    • Return appropriate HTTP error responses if the upload fails.
  6. Testing

    • Implement unit tests for the S3 URL generation logic.
    • Perform integration tests to validate that the upload to S3 via pre-signed URLs works correctly.

4. Sub-Tasks

  • S3 Bucket and IAM Setup**

  • Add AWS SDK to FastAPI**

  • Create FastAPI Route for Pre-Signed URL**

  • Security Enhancements**

  • Implement Error Handling**

  • Update Documentation**

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions