How it works#
Edge Storage is S3-compatible. Use @aws-sdk/client-s3 with Edge’s endpoint and credentials. For Compute, CDN, and DNS, call the REST API at https://api.edge.network using fetch() with your API key.
Storage: installing and configuring#
Install the AWS S3 client and presigner (for presigned URLs):
npm install @aws-sdk/client-s3 @aws-sdk/s3-request-presignerConfigure the client with Edge’s Storage endpoint and your access credentials (found in Console → Storage → Access Keys):
import { S3Client, CreateBucketCommand, PutObjectCommand, GetObjectCommand, ListObjectsV2Command } from '@aws-sdk/client-s3'
import { getSignedUrl } from '@aws-sdk/s3-request-presigner'
const s3 = new S3Client({
region: 'us-east-1',
endpoint: 'https://storage.edge.network',
forcePathStyle: true,
credentials: {
accessKeyId: process.env.EDGE_ACCESS_KEY,
secretAccessKey: process.env.EDGE_SECRET_KEY
}
})Set forcePathStyle: true. Edge Storage requires path-style access (for example, storage.edge.network/bucket/key).
Storage operations#
Create a bucket#
await s3.send(new CreateBucketCommand({ Bucket: 'my-bucket' }))Upload a file#
await s3.send(new PutObjectCommand({
Bucket: 'my-bucket',
Key: 'uploads/image.jpg',
Body: fileBuffer,
ContentType: 'image/jpeg'
}))List objects#
const { Contents } = await s3.send(new ListObjectsV2Command({
Bucket: 'my-bucket',
Prefix: 'uploads/'
}))Download a file#
const { Body } = await s3.send(new GetObjectCommand({
Bucket: 'my-bucket',
Key: 'uploads/image.jpg'
}))
const data = await Body.transformToByteArray()Generate a presigned URL#
import { getSignedUrl } from '@aws-sdk/s3-request-presigner'
const url = await getSignedUrl(s3, new GetObjectCommand({
Bucket: 'my-bucket',
Key: 'uploads/image.jpg'
}), { expiresIn: 3600 })Compute, CDN, DNS: REST API with fetch#
For non-Storage products, use fetch() against the Edge API:
const response = await fetch('https://api.edge.network/api/compute/vms', {
headers: {
'Authorization': `Bearer ${process.env.EDGE_API_KEY}`,
'Content-Type': 'application/json'
}
})
const { data } = await response.json()Use the same pattern for CDN deployments, DNS zones and records, and VM power operations. See the API reference for endpoint details.
Practical example: upload an image and get a share link#
Here’s a complete example that uploads an image and returns a presigned share link:
async function uploadAndShare(buffer, filename) {
const key = `uploads/${Date.now()}-${filename}`
await s3.send(new PutObjectCommand({
Bucket: 'my-bucket',
Key: key,
Body: buffer,
ContentType: 'image/jpeg'
}))
const shareUrl = await getSignedUrl(s3, new GetObjectCommand({
Bucket: 'my-bucket',
Key: key
}), { expiresIn: 86400 }) // 24 hours
return shareUrl
}Call this from an API route or serverless function. The returned URL can be shared with users. They can view or download the file without authenticating until the URL expires.
Keep learning
API & SDKs3 min read
Python SDK
Edge does not provide its own Python SDK. For Storage, use boto3. For Compute, CDN, and DNS, use the REST API with requests.
API & SDKs3 min read
Go SDK
Edge does not provide its own Go SDK. For Storage, use the AWS SDK for Go v2. For Compute, CDN, and DNS, use the REST API with net/http.
API & SDKs3 min read
API reference
Edge exposes a REST API for Compute, CDN, DNS, Storage and Shield. Use it to automate deployments, manage resources and integrate with your tooling.