npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@wiicode/s3-client

v1.0.4

Published

Official SDK client for WiiCode S3 Upload Service

Readme

@wiicode/s3-client

Official TypeScript/JavaScript SDK for WiiCode S3 Upload Service.

Installation

NPM (Recommended)

npm install @wiicode/s3-client

Yarn

yarn add @wiicode/s3-client

PNPM

pnpm add @wiicode/s3-client

Quick Start

import { WiiS3Client } from '@wiicode/s3-client';

const s3 = new WiiS3Client({
  endpoint: 'https://your-s3-service.com',
  apiKey: 'your_api_key',
});

// Upload a file
const file = await s3.upload(
  buffer,           // Buffer | Blob | File
  'photo.jpg',      // filename
  'image/jpeg',     // mimetype
  {
    userId: 'user-123',
    metadata: { category: 'avatar' }
  }
);

console.log(file.publicUrl);

Usage Examples

Node.js (Backend)

import { WiiS3Client } from '@wiicode/s3-client';
import * as fs from 'fs';

const s3 = new WiiS3Client({
  endpoint: process.env.WIIS3_ENDPOINT!,
  apiKey: process.env.WIIS3_API_KEY!,
});

// Upload from file system
const buffer = fs.readFileSync('./image.jpg');
const file = await s3.upload(buffer, 'image.jpg', 'image/jpeg');

console.log('Uploaded:', file.publicUrl);

// Get file info
const info = await s3.getFile(file.id);
console.log('File size:', info.size);

// Get presigned download URL (expires in 1 hour)
const { url } = await s3.getDownloadUrl(file.id);
console.log('Download URL:', url);

Note: Install form-data for Node.js:

npm install form-data

Browser/Frontend

import { WiiS3Client } from '@wiicode/s3-client';

const s3 = new WiiS3Client({
  endpoint: 'https://your-s3-service.com',
  apiKey: 'your_api_key',
});

// Upload from file input
const fileInput = document.querySelector('input[type="file"]');
const file = fileInput.files[0];

const uploaded = await s3.upload(file, file.name, file.type);
console.log('Uploaded:', uploaded.publicUrl);

// Display the image
document.querySelector('img').src = uploaded.publicUrl;

NestJS Integration

import { Injectable } from '@nestjs/common';
import { WiiS3Client } from '@wiicode/s3-client';
import { ConfigService } from '@nestjs/config';

@Injectable()
export class StorageService {
  private s3Client: WiiS3Client;

  constructor(private config: ConfigService) {
    this.s3Client = new WiiS3Client({
      endpoint: this.config.get('WIIS3_ENDPOINT'),
      apiKey: this.config.get('WIIS3_API_KEY'),
    });
  }

  async uploadFile(file: Express.Multer.File, userId: string) {
    return await this.s3Client.upload(
      file.buffer,
      file.originalname,
      file.mimetype,
      { userId }
    );
  }

  async getFileUrl(fileId: string) {
    const file = await this.s3Client.getFile(fileId);
    return file.publicUrl;
  }
}

API Reference

Constructor

new WiiS3Client(config: WiiS3Config)

WiiS3Config:

  • endpoint (string, required) - API endpoint URL
  • apiKey (string, required) - Tenant API key
  • timeout (number, optional) - Request timeout in ms (default: 30000)

Methods

upload(file, filename, mimetype, options?)

Upload a file to S3.

Parameters:

  • file (Buffer | Blob | File) - File data
  • filename (string) - Original filename
  • mimetype (string) - MIME type
  • options (UploadOptions, optional)
    • userId (string) - User identifier for organization
    • metadata (object) - Custom JSON metadata

Returns: Promise<UploadedFile>

{
  id: string;
  originalName: string;
  storedName: string;
  mimeType: string;
  size: number;
  publicUrl: string;
  uploadedAt: string;
}

getFile(fileId)

Get file metadata and public URL.

Parameters:

  • fileId (string) - File UUID

Returns: Promise<FileInfo>

{
  id: string;
  originalName: string;
  storedName: string;
  mimeType: string;
  size: number;
  publicUrl: string;
  userId?: string;
  metadata?: Record<string, any>;
  uploadedAt: string;
}

getDownloadUrl(fileId)

Generate a presigned download URL (valid for 1 hour).

Parameters:

  • fileId (string) - File UUID

Returns: Promise<DownloadUrlResponse>

{
  url: string;
  expiresIn: number; // 3600 seconds
}

Error Handling

import {
  WiiS3Client,
  AuthenticationError,
  ValidationError,
  NotFoundError,
  QuotaExceededError,
  NetworkError,
} from '@wiicode/s3-client';

try {
  const file = await s3.upload(buffer, 'file.jpg', 'image/jpeg');
} catch (error) {
  if (error instanceof AuthenticationError) {
    console.error('Invalid API key');
  } else if (error instanceof ValidationError) {
    console.error('File validation failed:', error.message);
  } else if (error instanceof QuotaExceededError) {
    console.error('Storage quota exceeded');
  } else if (error instanceof NotFoundError) {
    console.error('File not found');
  } else if (error instanceof NetworkError) {
    console.error('Network error:', error.message);
  }
}

Environment Variables

WIIS3_ENDPOINT=https://your-s3-service.com
WIIS3_API_KEY=your_api_key

Obtaining API Keys

Contact your service administrator to create a tenant and obtain an API key.


TypeScript Support

This package includes TypeScript definitions. No additional @types package needed.


License

MIT