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

@bigbangjs/file-storage-filesystem

v1.0.3

Published

Local filesystem adapter for @bigbangjs/file-storage

Downloads

3

Readme

💥 BigBangJS File Storage - Filesystem Provider

Filesystem provider for @bigbangjs/file-storage.


External/Peer dependencies:

[none]


🚀 Quick start

  1. Install the package using npm or yarn
$ npm i @bigbangjs/file-storage-filesystem
# or
$ yarn add @bigbangjs/file-storage-filesystem
  1. Register the provider globally in the storage
import {FilesystemProvider} from '@bigbangjs/file-storage-filesystem';

FileStorage.registerProviderType('fs', FilesystemProvider);
  1. Init the Storage and add a provider instance and buckets
import {FileStorage} from '@bigbangjs/file-storage';
import { FileSystemBucketConfig, FilesystemProvider, FileSystemProviderConfig } from '@bigbangjs/file-storage-filesystem';

// create a storage insance [FileStorageConfigOptions]
const storage = new FileStorage({
    defaultBucketMode: '0777',
    bucketAliasStrategy: 'NAME',
    autoInitProviders: true,
    autoCleanup: true,
    defaultBucketName: 'mybucket',
    returningByDefault: false,,
    logger: console,
});

// add a provider
const myProvider=(await storage.addProvider({
    uri: 'fs://<pathToRoot>',
    name:'myprovider'
})).result;

// add a bucket using object config
const myBucket=(await myProvider.addBucket({ root: 'bucket01', name:'bucket01' }));

// add a bucket using url object
const myBucket=(await myProvider.addBucket({ uri: 'myprovider://bucket02RootPath?name=bucket02' }));

// add a bucket using url string
const myBucket=(await myProvider.addBucket('myprovider://bucket03RootPath?name=bucket03'));

// the bucket is ready to use, for example, create a file
const fileUri= (await myBucket.putFile('directory/test.txt', 'Hello world!')).result;
//the response will be: myprovider://bucket01/directory/test.txt

💥 Provider configuration options

You can set the configuration of the provider as an "url" or a FileSystemProviderConfig object.

The url must be in the form:

<providerTypeName>://<pathToRoot>?name=<providerName>[&mode=0777][&signedUrlExpiration=3600][&autoCleanup=true|false]

The configuration object can have the following properties:

{
    // the name of the provider (required)
    name: string;
    // the root path in the filesystem (required)
    root: string;
    // write/read mode in octal or string format [default:'0777']
    mode?: string | number;
    // delete empty directories (recommended) [default:true]
    autoCleanup?: boolean;
    // signed url expiration (in seconds) [default:3600]
    defaultSignedUrlExpiration?: number;
    // buckets (will be added when the `init` method gets called)
    buckets?: (Partial<FileSystemBucketConfig> | string)[];
    // uri (optional) you can pass an uri as config
    uri?:string;
}

💥 Bucket configuration options

You can set the configuration of the provider as an "url" or a FileSystemBucketConfig object.

The url must be in the form:

<providerName>://<pathToRoot>?name=<bucketName>[&mode=0777][&signedUrlExpiration=3600][&autoCleanup=true|false]

The configuration object can have the following properties:

{
    // the name of the bucket (required)
    name: string;
    // uri (optional) you can pass an uri as config
    uri?: string;
    // the name of the provider (this is required when you add the bucket directly to the storage instance, not when you add it to the provider instance)
    providerName?: string;
   // write/read mode in octal or string format [default:'0777']
    mode?: string | number;
    // delete empty directories (recommended) [default:true]
    autoCleanup?: boolean;
    // signed url expiration (in seconds) [default:3600]
    defaultSignedUrlExpiration?: number;
}

MIT License

Copyright (c) 2020 Pablo Ramírez [email protected]