S3 Compatible Solutions to Connect Storx Programmatically
Here We have created some examples to connect storx with your application programmatically using golang and s3 utility packages.
Prerequisites
Before running the code, ensure you have the following prerequisites:
- Credentials created from dashboard.
- Go installed on your machine.
Security Considerations
It's important to handle access credentials securely. Avoid hardcoding credentials directly into the code. Instead, consider using environment variables or other secure methods for credential management. Additionally, ensure that IAM policies associated with the credentials provide the least privilege necessary for your application's functionality.
Dependencies in Go
Required Values
Required Objects
1. Creating a Session
The CreateSession function establishes a new session with the S3-compatible solution using provided credentials. Sessions are essential for making requests to S3-compatible services.
Example:
2. Creating a Bucket
The CreateBucket function creates a new bucket with the given name.
Example:
3. Listing Buckets
The ListBuckets function retrieves a list of all buckets associated with the account.
Example:
4. Creating a Folder in a Bucket
The CreateFolder function creates a folder (prefix) within an existing bucket.
Example:
5. Listing Files in a Bucket
The ListFilesInBucket function lists all files (objects) in a given bucket, optionally filtered by a specific path.
Example:
6. Uploading a File to a Bucket
The UploadFile function uploads a file to a specified location within an bucket.
Example: