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

do-spaces

v1.2.3

Published

Unofficial package for simple managing file operations hosted on "Digital Ocean Spaces" written in Typescript

Downloads

45

Readme

do-spaces

Unofficial package for simple managing file operations hosted on "Digital Ocean Spaces" written in Typescript

do-spaces unnoficial package readme banner

Motivation

I've created this package to ease working with spaces. Be more expressive then aws-sdk. And to solve "quirks" aws-sdk have (like uploading with mime-types, delete whole folder...)

Install

npm i do-spaces

Usage

// commonJS
const Spaces = require('do-spaces').default;
// ES6 modules
import Spaces from 'do-spaces';

const spaces = new Spaces({
  // under settings of bucket in digital ocean (e.g. nyc3.digitaloceanspaces.com)
  endpoint: `<endpoint>`,
  // in GLOBAL settings of digital ocean
  accessKey: `<access_key>`,
  // in GLOBAL settings of digital ocean
  secret: `<secret>`,
  // `https://<name_of_the_bucket>.<urlOfDigitalOcean>` (e.g. hello-world.nyc3.digitaloceanspaces.com so bucket is: hello-world );
  bucket: `<name_of_the_bucket>`,
});

Methods

  • every method takes optional awsParams to enhance/replace it's default configuration for underlying method. Configuration docs can be found here
  • path - string, path folder like (ending with /)
  • pathname -- string, full path to file (e.g /test/image.png)
  • all methods returns Promise
const spaces = new Spaces({
    endpoint: `<endpoint>`, // under settings of bucket in digital ocean
    accessKey: `<access_key>`, // in GLOBAL settings of digital ocean
    secret: `<secret>`, // in GLOBAL settings of digital ocean
    bucket: `<name_of_the_bucket>`,
});

// ....

// `s3.putObject`
await spaces.createFolder({
    path: `/some/test/path/`,
    awsParams // optional - `s3.putObject`
});

// ....

// recursively removes all files in specified folder
await spaces.deleteFolder({
  path: `/some/test/path/`,
  awsListParams, //optional - used to list items before deleting - `s3.listObjects`
  awsDeleteParams, // optional - used to delete `s3.deleteObjects`
});

// folders are automatically created, no need to create folders beforehand
// automatically determines mime-type
await spaces.uploadFile({
    pathname: `/some/test/path/myfile.txt`,
    privacy: "public-read", // 'private' | 'public-read' (DO supports only those)
    file,// Blob, string...
    awsParams  // optional - `s3.putObject`
});

await spaces.downloadFile({
    pathname: "/some/test/path/myfile.txt", // or link https://<bucket>.<endpoint>/path/to/file
    awsParams // optional -  `s3.getObject`
});

// if there are more then 1000 files you will receive in response `nextMarker`,
// to continue with listing
await spaces.listFiles({
    maxFiles = 1000, // optional - default is 1000 (max allowed in DO/AWS)
    path: `/some/test/path/` ,
    nextMarker, // optional - from which path it should start listing (supplied)
    awsParams, // optional - `s3.getObjects`
});

await spaces.copyFile({
    pathname: "/test/newFile.txt",
    copiedPathname: "/test/copied.txt",
    privacy: "public-read", // 'private' | 'public-read'
    fromBucket, // optional - different bucket name if copied from elsewhere
    awsParams, // optional -`s3.copyObject`
});

await spaces.deleteFile({
    pathname: "/test/remove_me.txt",
    awsParams // optional `s3.deleteObject`
});