Feature Request: Support for Direct Image Upload via S3 or Azure Blob Storage
a
animalnots
Description:
Currently, BetterGPT supports image uploads via base64 encoding. To enhance flexibility and scalability, we propose adding support for direct image uploads via Amazon S3 and Azure Blob Storage. This feature would allow users to automatically upload images to these cloud storage services and provide the URLs directly to the API, improving efficiency for large-scale applications.
Proposed Solution:
- S3 Integration:
- Allow users to configure their AWS credentials (API Key, Secret Key).
- Provide functionality to upload images directly to an S3 bucket.
- Generate and use the S3 URL for the image in API requests.
- Azure Blob Integration:
- Allow users to configure their Azure Storage credentials (Account Name, Account Key).
- Provide functionality to upload images directly to an Azure Blob container.
- Generate and use the Azure Blob URL for the image in API requests.
- API Changes:
- Modify the existing image upload (via blob64) to accept URLs from these cloud storage services.
- Add config sections for configuring AWS and Azure credentials.
- Library Dependencies:
- Add relevant libraries for AWS SDK for JavaScript:
```bash
npm install @aws-sdk/client-s3
```
- Add relevant libraries for Azure SDK for JavaScript:
```bash
npm install @azure/storage-blob
```
- Documentation Update:
- Update the API documentation to include examples and guidelines for using S3 and Azure Blob URLs.
- Provide instructions for setting up AWS and Azure credentials.
Benefits:
- Scalability:Supports large-scale image processing without the need for base64 encoding.
- Efficiency:Reduces the overhead of encoding/decoding images.
- Flexibility:Allows users to leverage existing cloud storage solutions.
- Automation:Simplifies the process by automatically handling the upload and URL generation.
Example Use Case:
```json
{
"model": "gpt-4o",
"messages": [
{
"role": "user",
"content": [
{ "type": "text", "text": "What’s in this image?" },
{ "type": "image_url", "url": "https://example.com/path-to-image.jpg" }
]
}
],
}
```
Configuration Endpoints:
- AWS S3 Configuration:
```json
{
"aws_access_key_id": "YOUR_AWS_ACCESS_KEY_ID",
"aws_secret_access_key": "YOUR_AWS_SECRET_ACCESS_KEY",
"s3_bucket_name": "YOUR_S3_BUCKET_NAME"
}
```
- Azure Blob Configuration:
```json
{
"azure_account_name": "YOUR_AZURE_ACCOUNT_NAME",
"azure_account_key": "YOUR_AZURE_ACCOUNT_KEY",
"azure_container_name": "YOUR_AZURE_CONTAINER_NAME"
}
```
Additional Information:
- Ensure security measures are in place to handle S3 and Azure Blob URLs.
- Validate the URLs to prevent unauthorized access.
- Handle error cases where the upload to S3 or Azure Blob fails.
Implementing this feature will significantly enhance the user experience and broaden the use cases for BetterGPT's vision capabilities.