Skip to content

teamzisty/evex-storage-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

evex-storage-sdk

A TypeScript SDK for the Evex Storage API with unlimited free storage.

Features

  • Upload files to Evex Storage
  • Download files by key
  • Support for multiple data formats (Blob, ArrayBuffer, Text)
  • Full TypeScript support
  • Error handling and validation
  • Built with Bun runtime

Installation

bun install evex-storage-sdk

Usage

Basic Setup

import EvexStorage from 'evex-storage-sdk';

const storage = new EvexStorage();

// Or with custom options
const storage = new EvexStorage({
  baseUrl: 'https://storage.evex.land' // default
});

Upload a File

// Upload from File object (browser)
const fileInput = document.querySelector('input[type="file"]');
const file = fileInput.files[0];
const result = await storage.upload(file, 'my-file.txt');

if (result.error) {
  console.error('Upload failed:', result.error);
} else {
  console.log('Download key:', result.downloadKey);
}

// Upload from Blob
const blob = new Blob(['Hello, world!'], { type: 'text/plain' });
const result = await storage.upload(blob, 'hello.txt');

// Upload from ArrayBuffer
const buffer = new ArrayBuffer(8);
const result = await storage.upload(buffer, 'data.bin');

Download a File

const downloadKey = 'your-download-key';

// Download as Response object
const response = await storage.download(downloadKey);
const blob = await response.blob();

// Download directly as Blob
const blob = await storage.downloadAsBlob(downloadKey);

// Download as ArrayBuffer
const buffer = await storage.downloadAsArrayBuffer(downloadKey);

// Download as Text
const text = await storage.downloadAsText(downloadKey);

API Reference

Constructor

new EvexStorage(options?: EvexStorageOptions)

Options

  • baseUrl?: string - Custom base URL for the API (default: https://storage.evex.land)
  • mirrorUrl?: string - Mirror URL (for future use)

Methods

upload(file, filename): Promise<UploadResponse>

Upload a file to Evex Storage.

Parameters:

  • file: File | Blob | ArrayBuffer | Uint8Array - The file data to upload
  • filename: string - The filename to use

Returns:

  • Promise<UploadResponse> - Upload result with downloadKey or error

download(downloadKey): Promise<Response>

Download a file by its download key.

Parameters:

  • downloadKey: string - The download key from upload response

Returns:

  • Promise<Response> - Fetch Response object

downloadAsBlob(downloadKey): Promise<Blob>

Download a file as a Blob.

downloadAsArrayBuffer(downloadKey): Promise<ArrayBuffer>

Download a file as an ArrayBuffer.

downloadAsText(downloadKey): Promise<string>

Download a file as text.

Types

interface UploadResponse {
  downloadKey?: string;
  error: string | null;
}

interface EvexStorageOptions {
  baseUrl?: string;
  mirrorUrl?: string;
}

Error Handling

The SDK throws errors for various failure scenarios:

try {
  const result = await storage.upload(file, 'test.txt');
  if (result.error) {
    // Handle API error
    console.error('API Error:', result.error);
  }
} catch (error) {
  // Handle network or other errors
  console.error('Upload failed:', error.message);
}

Development

Install dependencies:

bun install

Run tests:

bun test

API Endpoints

License

MIT

About

A TypeScript SDK for the Evex Storage API with unlimited free storage.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published