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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@veltahq/storage

v1.0.1

Published

Velta object storage interaction API.

Downloads

2

Readme

@veltahq/storage

Documentation

Installation

To use the Velta Object Storage package in your Node.js project, you need to install it via npm. Run the following command in your project directory:

npm install @veltahq/storage

Usage

Once installed, you can import the package in your code using the following statement:

import { Storage } from "@veltahq/storage";

To initialize the package, create a new instance of the Storage class with the required configuration options:

const s3 = new Storage({
  credentials: {
    accessKeyId: "YOUR_ACCESS_KEY_ID",
    secretAccessKey: "YOUR_SECRET_ACCESS_KEY",
  },
  region: "YOUR_REGION",
  bucket: "YOUR_BUCKET_NAME",
});

Replace the YOUR_ACCESS_KEY_ID, YOUR_SECRET_ACCESS_KEY, YOUR_REGION, and YOUR_BUCKET_NAME placeholders with your actual credentials and bucket information.

Methods

The s3 object (an instance of the Storage class) provides the following methods for interacting with the Velta Object Storage:

uploadObject(fileKey: string, fileData: ReadStream, contentType: any): Promise<string>

This method uploads a file to the Velta Object Storage with the specified file key, file data, and content type.

Parameters:

  • fileKey (string): The key to assign to the uploaded file.
  • fileData (ReadStream): The file data to be uploaded. It should be provided as a ReadStream.
  • contentType (any): The content type of the file. Returns: A Promise that resolves to a string representing the uploaded file's key.

Example:

import { ReadStream } from "fs";

const fileData: ReadStream = fs.createReadStream("path/to/file.jpg");
const contentType = "image/jpeg";
await s3.uploadObject("object.jpg", fileData, contentType);

getSignedUrl(fileKey: string, expirationTime?: number): Promise<string>

This method retrieves a signed URL for accessing the object with the specified file key in the Velta Object Storage.

Parameters:

  • fileKey (string): The key of the object for which to generate the signed URL.

  • expirationTime (optional, number): The expiration time in seconds for the signed URL. If not provided, a default expiration time will be used.

    Returns: A Promise that resolves to the signed URL as a string.

Example:

const signedUrl = await s3.getSignedUrl("object.jpg");

deleteObject(fileKey: string): Promise<string>

This method deletes the object with the specified file key from the Velta Object Storage.

Parameters:

  • fileKey (string): The key of the object to be deleted. Returns: A Promise that resolves to a string representing the key of the deleted object.

Example:

await s3.deleteObject("object.jpg");

listObjects(): Promise<string[] | any[]>

This method retrieves a list of objects in the Velta Object Storage.

Returns: A Promise that resolves to an array of strings representing the keys of the objects.

Example:

const objects = await s3.listObjects();
console.log(objects);

updateObjectName(oldObjectKey: string, newObjectKey: string): Promise<string>

This method updates the key of an existing object in the Velta Object Storage.

Parameters:

  • oldObjectKey (string): The current key of the object.
  • newObjectKey (string): The new key to assign to the object. Returns: A Promise that resolves to a string representing the updated key of the object.

Example:

await s3.updateObjectName("oldKey", "newKey");

createFolder(folderPath: string): Promise<string>

This method creates a new folder at the specified folder path in the Velta Object Storage.

Parameters:

  • folderPath (string): The path of the folder to be created. Returns: A Promise that resolves to a string representing the path of the created folder.

Example:

await s3.createFolder("path/to/folder");