githubEdit

Store An Object

triangle-exclamation

This guide demonstrates how to interact with the Flashback Platform to upload and download files in your application backend:

Prerequisites

Install Required Packages

pip install boto3 google-cloud-storage azure-storage-blob

AWS S3

1

Configuration

Set up the S3 client with your Flashback endpoint and credentials:

# flashback_aws_config.py
import boto3
from botocore.client import Config

# Replace with your Flashback credentials and endpoint
ENDPOINT = "https://s3-us-east-1-aws.flashback.tech"
# Consider READ/WRITE API Information of the Repository
API_KEY_ID = "YOUR_API_KEY_ID" 
API_SECRET = "YOUR_API_SECRET"

session = boto3.session.Session(
    aws_access_key_id=API_KEY_ID,
    aws_secret_access_key=API_SECRET
)

s3_client = session.client(
    service_name="s3",
    endpoint_url=ENDPOINT,
    config=Config(signature_version="s3v4")
)
2

Upload a File

Upload a local file to your specified bucket:

# aws_upload.py
from flashback_aws_config import s3_client

#S3 Bucket, GCS Bucket, or Azure Container listed in your Repository
BUCKET_NAME = "your-bucket-name"
FILE_PATH = "path/to/local/file.txt"
OBJECT_NAME = FILE_PATH.split("/")[-1]

s3_client.upload_file(
    Filename=FILE_PATH,
    Bucket=BUCKET_NAME,
    Key=OBJECT_NAME
)
print(f"Uploaded {OBJECT_NAME} to {BUCKET_NAME}")
3

Download a File

Download an object from your repository to a local path:

# aws_download.py
from flashback_aws_config import s3_client

#S3 Bucket, GCS Bucket, or Azure Container listed in your Repository
BUCKET_NAME = "your-bucket-name"
OBJECT_NAME = "file.txt"
DEST_PATH = "downloads/file.txt"

s3_client.download_file(
    Bucket=BUCKET_NAME,
    Key=OBJECT_NAME,
    Filename=DEST_PATH
)
print(f"Downloaded {OBJECT_NAME} to {DEST_PATH}")

Google Cloud Storage

1

Configuration

Initialize a GCS client pointing to your Flashback Bridge endpoint:

2

Upload a File as a Blob

Upload a blob to the specified GCS bucket:

3

Download a File as a Blob

Download a blob from your repository:


Azure Blob Storage

1

Configuration

Create an Azure BlobServiceClient using your Flashback endpoint:

2

Upload a File as a Blob

Upload a local file as a blob to your bucket:

3

Download a File as a Blob

Download a blob from your container to a local path:


Next Steps

  • Explore additional storage API operations: delete, copy, multipart uploads, etc.

  • Integrate and modify these snippets into your applications.

Last updated

Was this helpful?