-
Couldn't load subscription status.
- Fork 3
S3 Compatible Vendors
Various vendors expose their own S3-like APIs, usually branded as an Object Storage service.
If you want to connect to a service that has a URL like <region>.service.com,
then the S3CompatibleEndpointResolver provided by /x/aws_api should do the trick.
You can import the class alongside the main ApiFactory class:
import {
ApiFactory,
S3CompatibleEndpointResolver,
} from "https://deno.land/x/aws_api/client/mod.ts";
import { S3 } from "https://deno.land/x/aws_api/services/s3/mod.ts";Note that /x/aws_api will continue to look at AWS_* environment variables
for credentials and region configuration.
So you'll still use AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
If you want to change the environment variable names, provide your own credential structure:
export const doApi = new ApiFactory({
endpointResolver: new S3CompatibleEndpointResolver('digitaloceanspaces.com'),
credentials: {
awsAccessKeyId: Deno.env.get("DO_ACCESS_KEY_ID")!,
awsSecretKey: Deno.env.get("DO_SECRET_ACCESS_KEY")!,
},
region: Deno.env.get("DO_REGION"),
}).makeNew(S3);Alternatively, create an EnvironmentCredentials instance:
export const doApi = new ApiFactory({
endpointResolver: new S3CompatibleEndpointResolver('digitaloceanspaces.com'),
credentialProvider: new EnvironmentCredentials('DO'),
region: Deno.env.get("DO_REGION"),
}).makeNew(S3);Below are a few vendors and some example code for each.
NOTE: Only the endpoints have been confirmed for many of these! If you have success with one, or if you have errors, please report either way so documentation can be updated.
The regions look like nyc3, sfo2, fra1, etc.
const api = new ApiFactory({
endpointResolver: new S3CompatibleEndpointResolver('digitaloceanspaces.com'),
}).makeNew(S3);Functionality: ❓ Untested
The regions are similar to AWS's: ap-south-1, eu-central-1, us-east-1, etc.
const api = new ApiFactory({
endpointResolver: new S3CompatibleEndpointResolver('linodeobjects.com'),
}).makeNew(S3);Functionality: ❓ Untested
There's only one region, so it's specified inline below.
const api = new ApiFactory({
endpointResolver: new S3CompatibleEndpointResolver('vultrobjects.com'),
region: 'ewr1', // the only region that exists as of writing this
}).makeNew(S3);Functionality: ✔️ Tested
Backblaze has a different URL structure which isn't accounted for by the S3 resolver.
So for now used fixedEndpoint:
const api = new ApiFactory({
fixedEndpoint: "https://s3.us-west-001.backblazeb2.com",
region: "us-west-001",
}).makeNew(S3);Functionality: ❓ Untested
As of writing, R2 requires path-style routing, otherwise a 500 is returned.
The buckets are also scoped to a per-account namespace
and there is no choice of regions.
This is a good fit for fixedEndpoint:
const api = new ApiFactory({
fixedEndpoint: `https://${Deno.env.get('R2_ACCOUNT')}.r2.cloudflarestorage.com`,
region: 'auto', // cloudflare r2 only has one region
}).makeNew(S3);Functionality:
- ✔️ Basic operations work
- ❓ R2 itself is still in beta