# Telnyx Storage: Object Storage — Full Documentation
> Complete page content for Object Storage (Storage section) of the Telnyx developer docs (https://developers.telnyx.com).
> This file: https://developers.telnyx.com/docs/development/llms/storage-object-storage-llms-full-txt.md · Root index: https://developers.telnyx.com/llms.txt
## Overview
### Overview
> Source: https://developers.telnyx.com/docs/cloud-storage/overview.md
S3-compatible object storage for files, media, backups, and static assets — reached over the AWS S3 API you already know, or directly from inside a Telnyx Edge Function.
With Telnyx Cloud Storage, you can:
- **Use your existing S3 tooling** — the AWS SDKs, AWS CLI, and third-party S3 clients work unchanged; authenticate with your Telnyx API key
- **Store data in the US, EU, AP, or CA** — buckets in `us-central-1`, `us-east-1`, `us-west-1`, `eu-central-1`, `ap-southeast-1`, and `ca-central-1`
- **Reach buckets from Edge Compute** — bind a bucket to a function and read or write objects with no S3 keys in your code
- **Control access and lifecycle** — presigned URLs, public buckets, object lock and retention, SSE-C encryption, and lifecycle rules
- **Pay for what you use** — a monthly free tier plus simple usage-based pricing
Create a bucket, generate S3 credentials, and upload your first object
Bind a bucket and read or write objects with no S3 keys in your code
Copy-paste examples for Node, Python, Java, Go, Ruby, PHP, .NET, and Elixir
Regional endpoints and how requests are routed
---
## Ways to access
From inside a Telnyx Edge Function — pre-authenticated, no S3 keys
Node, Python, Java, Go, Ruby, PHP, .NET, or Elixir
Scripting and one-off operations from a terminal
Move data at scale without code
## Learn the essentials
Some behavior differs from AWS S3 — review these before going to production:
- [Compatibility matrix](/docs/cloud-storage/supported) — which S3 operations are supported, by region
- [Authentication](/docs/cloud-storage/authentication) — your Telnyx API key as the S3 credential
- [Presigned URLs](/docs/cloud-storage/presigned-urls) — the Telnyx-specific way to generate them safely
- [Billing](/docs/cloud-storage/billing) — storage and request pricing
---
## Get Started
### Quick Start Guide
> Source: https://developers.telnyx.com/docs/cloud-storage/quick-start.md
There are five ways to get started on Telnyx cloud storage:
1. [Cloud Storage binding](/docs/cloud-storage/bindings) — from inside a Telnyx Edge Function
2. [AWS SDK](#use-the-aws-sdk)
3. [AWS CLI](#use-the-aws-cli)
4. [S3-compatible third-party tools](#use-s3-compatible-third-party-tools)
5. [Telnyx Mission Control Portal](#use-the-telnyx-mission-control-portal)
## Available Regions
| Region | Endpoint |
|--------|----------|
| us-central-1 | us-central-1.telnyxcloudstorage.com |
| us-east-1 | us-east-1.telnyxcloudstorage.com |
| us-west-1 | us-west-1.telnyxcloudstorage.com |
| eu-central-1 | eu-central-1.telnyxcloudstorage.com |
| ap-southeast-1 | ap-southeast-1.telnyxcloudstorage.com |
| ca-central-1 | ca-central-1.telnyxcloudstorage.com |
Specify the region via the `--endpoint-url` flag in the AWS CLI or the equivalent SDK configuration. See [API Endpoints & Organization](/docs/cloud-storage/api-endpoints) for details on regional behavior.
Some features are currently available only in US, APAC, and CA regions, including presigned URLs, public buckets, and SSL certificates. EU buckets do not support these features. See the [compatibility matrix](/docs/cloud-storage/supported) for full details.
## Use a Cloud Storage binding
Bind an existing bucket to a [Telnyx Edge Function](/docs/edge-compute/overview) and read, write, and list objects through a pre-authenticated `env` binding — the runtime injects the credential, so your code holds no S3 keys. This is the fastest path if your code already runs on Telnyx Edge Compute.
See [Use a bucket from an Edge Function](/docs/cloud-storage/bindings) to declare the binding and call `env.MY_BUCKET.get/put/head/delete/list`.
## Use the AWS SDK
Telnyx Cloud Storage is S3-compatible, so the AWS SDKs work against it. See the ready-to-run examples for [Node](/docs/cloud-storage/sdk/node), [Python](/docs/cloud-storage/sdk/python), [Java](/docs/cloud-storage/sdk/java), [Go](/docs/cloud-storage/sdk/golang), [Ruby](/docs/cloud-storage/sdk/ruby), [PHP](/docs/cloud-storage/sdk/php), [.NET](/docs/cloud-storage/sdk/dotnet), and [Elixir](/docs/cloud-storage/sdk/elixir).
## Use the AWS CLI
Follow the procedure [here](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html).
Use a recent AWS CLI v2. The Cloud Storage endpoint accepts the AWS CLI's default checksums (CRC64NVME) on both `put-object` and `aws s3 cp` multipart uploads.
- Inject your Telnyx [API key](https://portal.telnyx.com/#/api-keys) twice, once as access key and once as secret key.
- Leave the region as blank; regionality is specified via `--endpoint-url` as shown subsequently.
```json
user@localhost ~ % aws configure --profile mytelnyxprofile
AWS Access Key ID [None]: XXX
AWS Secret Access Key [None]: XXX
Default region name [None]:
Default output format [None]: json
```
Validate the profile has been created successfully.
```json
user@localhost ~ % aws configure list-profiles
mytelnyxprofile
```
Perform the following validation procedure to ensure everything is working as expected.
**Create 2 buckets**
Bucket names must be universally unique. Hence, `BucketAlreadyExists` error is expected on first attempt.
```json
user@localhost ~ % aws s3api create-bucket --bucket demo-bucket --profile mytelnyxprofile --endpoint-url https://us-east-1.telnyxcloudstorage.com
An error occurred (BucketAlreadyExists) when calling the CreateBucket operation: Unknown
user@localhost ~ % aws s3api create-bucket --bucket demo-bucket-n1 --profile mytelnyxprofile --endpoint-url https://us-east-1.telnyxcloudstorage.com
user@localhost ~ % aws s3api create-bucket --bucket demo-bucket-n2 --profile mytelnyxprofile --endpoint-url https://us-east-1.telnyxcloudstorage.com
```
**List buckets**
Verify the buckets were created successfully.
```json
user@localhost ~ % aws s3api list-buckets --profile mytelnyxprofile --endpoint-url https://us-east-1.telnyxcloudstorage.com
{
"Buckets": [
{
"Name": "demo-bucket-n1",
"CreationDate": "2024-07-26T17:31:14.888000+00:00"
},
{
"Name": "demo-bucket-n2",
"CreationDate": "2024-07-26T17:31:25.225000+00:00"
}
],
"Owner": {
"DisplayName": "XXX",
"ID": "XXX"
}
}
```
**Add objects to a bucket**
Upload some random objects.
```json
user@localhost ~ % aws s3api put-object --key demo-obj-101 --body ~/Downloads/IMG_1752.mov --bucket demo-bucket-n1 --profile mytelnyxprofile --endpoint-url https://us-east-1.telnyxcloudstorage.com
{
"ETag": "\"bc864c2bc4549d72abadb0a5d44ee788\""
}
user@localhost ~ % aws s3api put-object --key demo-obj-202 --body ~/Downloads/IMG_1753.mov --bucket demo-bucket-n1 --profile mytelnyxprofile --endpoint-url https://us-east-1.telnyxcloudstorage.com
{
"ETag": "\"bc864c2bc4549d72babdb0a5d44ee988\""
}
```
**List objects**
Verify the objects were uploaded successfully.
```json
user@localhost ~ % aws s3api list-objects-v2 --bucket demo-bucket-n1 --profile mytelnyxprofile --endpoint-url https://us-east-1.telnyxcloudstorage.com
{
"Contents": [
{
"Key": "demo-obj-101",
"LastModified": "2024-07-26T17:34:52.428000+00:00",
"ETag": "\"bc864c2bc4549d72abadb0a5d44ee788\"",
"Size": 136994934,
"StorageClass": "STANDARD"
},
{
"Key": "demo-obj-202",
"LastModified": "2024-07-26T17:36:31.799000+00:00",
"ETag": "\"bc864c2bc4549d72babdb0a5d44ee988\"",
"Size": 136994934,
"StorageClass": "STANDARD"
}
],
"RequestCharged": null
}
```
## Use S3-compatible third-party tools
Many excellent tools exist to upload data at scale without any code. You can find the configuration guides [here](https://support.telnyx.com/en/collections/3840515-telnyx-storage).
## Use the Telnyx Mission Control Portal
Follow [this support article](https://support.telnyx.com/en/articles/8344129-get-started-with-telnyx-storage-inference-guide).
The Mission Control Portal is not the right tool to:
Use the `aws s3 cp` CLI command or [multipart upload API](/docs/cloud-storage/multipart-upload) for more concurrency, better reliability, and bigger throughput.
Use one of the S3 compatible [third party tools](https://support.telnyx.com/en/collections/3840515-telnyx-storage) when moving large object counts.
## Read these documentations
Some key differences exist between Telnyx cloud storage and AWS S3. It's advisable that they are reviewed and comprehended prior to Telnyx cloud storage is put into production.
- Understand [API endpoints & organizations](/docs/cloud-storage/api-endpoints)
- Review [supported API methods](/docs/cloud-storage/supported)
- Heed the [warning on presigned URL](/docs/cloud-storage/presigned-urls)
- Pay attention to [billing](/docs/cloud-storage/billing)
- Know the [restrictions on policy and ACL](/docs/cloud-storage/public-buckets)
## Additional Resources
- All available [AWS S3 CLI Commands](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3api/index.html)
---
## Concepts
### API Endpoints & Organization
> Source: https://developers.telnyx.com/docs/cloud-storage/api-endpoints.md
There exists two suites of Storage APIs:
- S3 compatible, and
- JSON companion
## S3 Compatible APIs
This suite of APIs is compatible with AWS S3; as a result, minimal changes to existing integration are needed for migration to Telnyx.
Endpoint URL
Region
us-central-1.telnyxcloudstorage.com
us-central-1
us-east-1.telnyxcloudstorage.com
us-east-1
us-west-1.telnyxcloudstorage.com
us-west-1
eu-central-1.telnyxcloudstorage.com
eu-central-1
ap-southeast-1.telnyxcloudstorage.com
ap-southeast-1
ca-central-1.telnyxcloudstorage.com
ca-central-1
`ListBuckets` and `GetBucketLocation` are global: any regional endpoint returns every bucket in your account regardless of the region it is homed in. However, all other API methods need to be directed at the regional endpoint that the bucket is homed. Otherwise an error will be returned. Hence, it is advisable to query the location of the bucket first before forming the correct regional endpoint for all subsequent API operations.
Supported S3 APIs are documented in [this table](/docs/cloud-storage/supported).
## JSON Companion API
This suite of APIs is an extension to the S3 API, accommodating the following functionalities:
- [Querying usage](/docs/cloud-storage/billing)
- [Create presigned URL](/docs/cloud-storage/presigned-urls)
- [Manage SSL](/docs/cloud-storage/ssl-certificates)
- [Migrating data from AWS S3](/docs/cloud-storage/migrating-from-aws)
API endpoint to be used is `api.telnyx.com`.
---
### Authentication
> Source: https://developers.telnyx.com/docs/cloud-storage/authentication.md
API requests are authenticated with [API Keys](https://portal.telnyx.com/#/api-keys).
Telnyx Storage requires passing an AWS Signature Version 4 authorization header in the API request. Telnyx Storage also requires that the Telnyx API key is substituted into the authorization header as the `access-key-id`. When an API request is made, Telnyx will parse the API key from the header, validate it, and then authorize the request.
The remaining components of the authorization header (`date`, `aws-region`, `aws-service`, `secret-key`) are irrelevant to us. These values, as well as the generated signature from the secret key are all ignored. They only remain in the authorization header to maintain S3 compatibility. As long as you are passing an AWS Signature Version 4 authorization header, and the Telnyx API key is substituted into the header as the `access-key-id`, the request can be authenticated.
An example is shown below, where `{{your_telnyx_api_key_here}}` is where you will substitute in your Telnyx API Key:
```bash
Authorization: AWS4-HMAC-SHA256
Credential={{your_telnyx_api_key_here}}/20221129/us-east-1/s3/aws4_request,
SignedHeaders=host;range;x-amz-date,
Signature=d82d11938fe5edf39a778ec710ac79899bae1d9a46ae36607be30fb55f655a3c
```
After pasting the above content, remove any new line added.
## AWS CLI and S3 third party applications
A general rule of thumb when trying to use Telnyx Storage with a third party application is:
* `Access Key` → substitute in the Telnyx API token
* `Secret Access Key` → either leave blank, or type something random in as a placeholder, or duplicate Telnyx API tokens
---
### Bucket Addressing
> Source: https://developers.telnyx.com/docs/cloud-storage/bucket-addressing.md
## Path-style requests
`https://[region].telnyxcloudstorage.com/[bucketname]/[objectname]`
## Virtual-hosted-style requests
`https://[bucketname].[region].telnyxcloudstorage.com/[objectname]`
---
## Access via S3 API
### Node.js
> Source: https://developers.telnyx.com/docs/cloud-storage/sdk/node.md
Recent AWS SDK v3 versions work against Cloud Storage with default checksum settings. If you hit a checksum error on an older v3 release, set all checksum calculation and validation options to `WHEN_REQUIRED` (as shown in the client config below).
The following example shows how the AWS Node.js SDK can be used to interact with Telnyx Cloud Storage.
```javascript
const { S3Client, CreateBucketCommand, PutObjectCommand, ListObjectsCommand, GetObjectCommand } = require("@aws-sdk/client-s3");
const axios = require("axios");
const { v4: uuidv4 } = require("uuid");
const telnyxApiKey = process.env.TELNYX_API_KEY;
if (!telnyxApiKey) {
console.error("TELNYX_API_KEY environment variable not set");
process.exit(1);
}
const endpointUrl = "https://us-central-1.telnyxcloudstorage.com";
// 1. Initialize the AWS S3 client with specific options
const s3Client = new S3Client({
endpoint: endpointUrl,
region: "us-central-1",
credentials: {
accessKeyId: telnyxApiKey,
secretAccessKey: telnyxApiKey
},
forcePathStyle: true,
requestChecksumCalculation: 'WHEN_REQUIRED',
requestChecksumValidation: 'WHEN_REQUIRED',
responseChecksumCalculation: 'WHEN_REQUIRED',
responseChecksumValidation: 'WHEN_REQUIRED'
});
(async () => {
// 2. Create a bucket
const bucketName = `my-test-bucket-${uuidv4()}`;
await s3Client.send(new CreateBucketCommand({ Bucket: bucketName }));
// 3. Upload two objects with random data
for (let i = 0; i < 2; i++) {
const name = `my-test-object-${i}`;
const body = `Telnyx Cloud Storage ${i}`;
await s3Client.send(new PutObjectCommand({ Bucket: bucketName, Key: name, Body: body }));
}
// 4. List objects in the bucket
const listResult = await s3Client.send(new ListObjectsCommand({ Bucket: bucketName }));
(listResult.Contents || []).forEach(obj => {
console.log(obj.Key);
});
// 5. Download the first object
const getResult = await s3Client.send(new GetObjectCommand({ Bucket: bucketName, Key: "my-test-object-0" }));
const streamToString = (stream) => new Promise((resolve, reject) => {
const chunks = [];
stream.on("data", (chunk) => chunks.push(chunk));
stream.on("error", reject);
stream.on("end", () => resolve(Buffer.concat(chunks).toString("utf-8")));
});
console.log(await streamToString(getResult.Body));
// 6. Create a presigned URL for the first file
const presignResponse = await axios.post(
`https://api.telnyx.com/v2/storage/buckets/${bucketName}/my-test-object-0/presigned_url`,
{ ttl: 30 },
{ headers: { Authorization: `Bearer ${telnyxApiKey}` } }
);
console.log(presignResponse.data);
// 7. Download the file using the presigned URL
const fileResponse = await axios.get(presignResponse.data.data.presigned_url);
console.log(fileResponse.data);
})();
```
---
### Python
> Source: https://developers.telnyx.com/docs/cloud-storage/sdk/python.md
Recent boto3 versions (1.36+) work against Cloud Storage with default checksum settings. If you hit a checksum error, disable checksum calculation and verification with the `Config` shown below.
The following example shows how AWS Python SDK can be used to interact with Telnyx Cloud Storage.
```python
import requests
import uuid
import os
from botocore.config import Config
import boto3
# Only perform CRC checks `when_required`
config = Config(
request_checksum_calculation="when_required",
response_checksum_validation="when_required",
)
telnyx_api_key = os.getenv("TELNYX_API_KEY")
if not telnyx_api_key:
print("TELNYX_API_KEY environment variable not set")
exit(1)
# 1. Initialize the AWS client with specific options
client = boto3.client(
"s3",
endpoint_url="https://us-central-1.telnyxcloudstorage.com",
aws_access_key_id=telnyx_api_key,
aws_secret_access_key=telnyx_api_key,
config=config
)
# 2. Create a bucket
bucket_name = f"my-test-bucket-{uuid.uuid4()}"
client.create_bucket(Bucket=bucket_name)
# 3. Upload two objects with random data
for i in range(2):
name = f"my-test-object-{i}"
body = f"Telnyx Cloud Storage {i}"
client.put_object(Bucket=bucket_name, Key=name, Body=body)
# 4. List objects in the bucket
for obj in client.list_objects(Bucket=bucket_name)["Contents"]:
print(obj["Key"])
# 5. Download the first object
result = client.get_object(Bucket=bucket_name, Key="my-test-object-0")
print(result["Body"].read())
# 6. Create a presigned URL for the first file
response = requests.post(
f"https://api.telnyx.com/v2/storage/buckets/{bucket_name}/my-test-object-0/presigned_url",
json={"ttl": 30},
headers={"Authorization": f"Bearer {telnyx_api_key}"},
)
body = response.json()
print(body)
# 7. Download the file using the presigned URL
response = requests.get(body["data"]["presigned_url"])
print(response.text)
```
---
### Java
> Source: https://developers.telnyx.com/docs/cloud-storage/sdk/java.md
If you hit a checksum error with AWS SDK for Java v2 (2.30+), set request checksum calculation and response checksum validation to `WHEN_REQUIRED`, as shown in the client builder below.
The following example shows how AWS Java SDK can be used to interact with Telnyx Cloud Storage.
## Add Dependency
```
software.amazon.awssdk
s3
2.20.0
```
## Create S3 Bucket
```
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.model.CreateBucketRequest;
import java.net.URI;
public class CreateBucket {
public static void main(String[] args) {
String bucketName = "--your-bucket-name--";
Region region = Region.US_EAST_1;
String telnyxUrl = "https://us-central-1.telnyxcloudstorage.com";
String telnyxApiKey = "-- api key --";
// Create an S3 client
S3Client s3 = S3Client.builder()
.region(region)
.endpointOverride(URI.create(telnyxUrl))
// Only perform CRC checks `when_required`
.requestChecksumCalculation(RequestChecksumCalculation.WHEN_REQUIRED)
.responseChecksumValidation(ResponseChecksumValidation.WHEN_REQUIRED)
.credentialsProvider(
StaticCredentialsProvider.create(AwsBasicCredentials.create(telnyxApiKey, "does not matter")))
.build();
// create bucket
CreateBucketRequest createBucketRequest = CreateBucketRequest.builder()
.bucket(bucketName)
.build();
s3.createBucket(createBucketRequest);
System.out.println("Bucket created successfully: " + bucketName);
// Close the S3 client
s3.close();
}
}
```
## Upload an Object
```
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
import software.amazon.awssdk.core.sync.RequestBody;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.model.PutObjectRequest;
import java.net.URI;
import java.nio.file.Paths;
public class UploadObjectToS3 {
public static void main(String[] args) {
String bucketName = "--your-bucket-name--";
String keyName = "your-object-key";
String filePath = "--path to file for upload--";
Region region = Region.US_EAST_1;
String telnyxUrl = "https://us-central-1.telnyxcloudstorage.com";
String telnyxApiKey = "--your api key --";
// Create an S3 client
S3Client s3 = S3Client.builder()
.region(region)
.endpointOverride(URI.create(telnyxUrl))
.credentialsProvider(
StaticCredentialsProvider.create(AwsBasicCredentials.create(telnyxApiKey, "does not matter")))
.build();
// upload object
PutObjectRequest putObjectRequest = PutObjectRequest.builder()
.bucket(bucketName)
.key(keyName)
.build();
// Upload the file to S3
s3.putObject(putObjectRequest, RequestBody.fromFile(Paths.get(filePath)));
// Close the S3 client
s3.close();
}
}
```
## List Objects
```
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.model.ListObjectsV2Request;
import software.amazon.awssdk.services.s3.model.ListObjectsV2Response;
import software.amazon.awssdk.services.s3.model.S3Object;
import java.net.URI;
public class ListObjects {
public static void main(String[] args) {
String bucketName = "--your-bucket-name--";
Region region = Region.US_EAST_1;
String telnyxUrl = "https://us-central-1.telnyxcloudstorage.com";
String telnyxApiKey = "--your api key --";
// Create an S3 client
S3Client s3 = S3Client.builder()
.region(region)
.endpointOverride(URI.create(telnyxUrl))
.credentialsProvider(
StaticCredentialsProvider.create(AwsBasicCredentials.create(telnyxApiKey, "does not matter")))
.build();
// Create a ListObjectsV2Request
ListObjectsV2Request listObjectsRequest = ListObjectsV2Request.builder()
.bucket(bucketName)
.build();
// Get the list of objects in the bucket
ListObjectsV2Response listObjectsResponse = s3.listObjectsV2(listObjectsRequest);
for (S3Object s3Object : listObjectsResponse.contents()) {
System.out.println( s3Object.key());
}
// Close the S3 client
s3.close();
}
}
```
## Download Object
```
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
import software.amazon.awssdk.core.ResponseBytes;
import software.amazon.awssdk.core.sync.ResponseTransformer;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.model.GetObjectRequest;
import software.amazon.awssdk.services.s3.model.GetObjectResponse;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URI;
public class DownloadObject {
public static void main(String[] args) throws IOException {
String bucketName = "--your-bucket-name--";
Region region = Region.US_EAST_1;
String telnyxUrl = "https://us-central-1.telnyxcloudstorage.com";
String telnyxApiKey = "--your api key --";
String keyName = "your-object-key";
S3Client s3 = S3Client.builder()
.region(region)
.endpointOverride(URI.create(telnyxUrl))
.credentialsProvider(
StaticCredentialsProvider.create(AwsBasicCredentials.create(telnyxApiKey, "does not matter")))
.build();
// Create a GetObjectRequest
GetObjectRequest getObjectRequest = GetObjectRequest.builder()
.bucket(bucketName)
.key(keyName)
.build();
// Download the object and transform the response to a byte array
ResponseBytes objectBytes = s3.getObject(getObjectRequest, ResponseTransformer.toBytes());
// Write the file to the specified path
File downloadedFile = new File("-- path to where to save the file --");
try (FileOutputStream fos = new FileOutputStream(downloadedFile)) {
fos.write(objectBytes.asByteArray());
System.out.println("File downloaded successfully to -- path to where to save the file --");
}
// Close the S3 client
s3.close();
}
}
```
## Generate Presigned URLs for Upload and Download
In order for this part to work, we will need to add json decoding library and http client. Any libraries will do, but for this example we picked: gson and okhttp3.
```
com.squareup.okhttp3
okhttp
4.9.2
com.google.code.gson
gson
2.8.7
```
```
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import okhttp3.*;
import java.io.IOException;
import java.util.Map;
public class GeneratePresignedURLAndDownloadObject {
public static void main(String[] args) throws IOException {
OkHttpClient httpClient = new OkHttpClient();
Gson gson = new Gson();
String presignedUrlRequestJson = gson.toJson(Map.of("ttl", 30));
RequestBody presignedUrlRequestBody = RequestBody.create(MediaType.parse("application/json"), presignedUrlRequestJson);
Request presignedUrlRequest = new Request.Builder()
.url("https://api.telnyx.com/v2/storage/buckets/-- name of the bucket --/--name of the object--/presigned_url")
.header("Authorization", "Bearer --your api key---")
.post(presignedUrlRequestBody)
.build();
try (Response response = httpClient.newCall(presignedUrlRequest).execute()) {
if (!response.isSuccessful()) {
throw new IOException("Failed to create presigned URL: " + response);
}
String responseBody = response.body().string();
Map responseBodyMap = gson.fromJson(responseBody, new TypeToken