Getting Started
Quickstart
Install Fileway and upload your first file
Install
npm install @fileway/coreThen add the drivers you need:
npm install @fileway/driver-local
npm install @fileway/driver-s3
npm install @fileway/driver-cloudinaryUpload your first file
import { FilewayClient } from "@fileway/core";
import { LocalDriver } from "@fileway/driver-local";
const client = new FilewayClient({
driver: new LocalDriver({
directory: "./storage",
baseUrl: "https://cdn.example.com",
}),
});
const stream = new ReadableStream({
start(controller) {
controller.enqueue(new TextEncoder().encode("file content"));
controller.close();
},
});
const result = await client.upload(stream, {
filename: "readme.txt",
path: "docs",
mimeType: "text/plain",
});
console.log(result.id);
console.log(result.url);
console.log(result.path);
console.log(result.size);Type inference
Each driver returns its own metadata shape:
import { LocalDriver } from "@fileway/driver-local";
import { S3Driver } from "@fileway/driver-s3";
const localClient = new FilewayClient({
driver: new LocalDriver({ directory: "./storage" }),
});
const s3Client = new FilewayClient({
driver: new S3Driver({ bucket: "my-bucket", region: "us-east-1" }),
});
const localResult = await localClient.upload(stream, { filename: "f.txt" });
localResult.meta.localPath; // string
const s3Result = await s3Client.upload(stream, { filename: "f.txt" });
s3Result.meta.bucket; // string
s3Result.meta.etag; // string | undefinedNext steps
- See the Feature overview for what every driver supports.
- Deep-dive into uploads, downloads, and metadata.
- Handle failures with the observability guide.
- Find the full API reference for every method and option.