Giter VIP home page Giter VIP logo

now-storage's Introduction

Now Storage

Use Now static deployments to upload and store files.

Usage

Install it with yarn

yarn add now-storage

Or with npm

npm i now-storage

Then load it inside your app.

const { upload } = require('now-storage');

And call the upload function with your the Now token and the file to upload.

const { url } = await upload(process.env.NOW_TOKEN, {
  name: 'my-file.txt',
  content: 'This is a file uploaded with now-storage.'
});

The url is going to be a string similar to http://now-storage-bmjowtcani.now.sh/.

Configuration

All the deployments are going to have the name now-storage and the upload function is going to retry maximum 3 times to upload the file and another 3 times to create the deployment.

That could be configured passing a third argument to the upload method with an object using the following format.

await upload(process.env.NOW_TOKEN, {
  name: 'my-file.txt',
  content: 'This is a file uploaded with now-storage.'
}, {
  deploymentName: 'now-storage',
  retry: {
    retries: 3
  }
});

That's the default configuration, the retry key could receive any configuration from async-retry.

To deploy to a team account instead of your personal account add teamId to the config.

await upload(process.env.NOW_TOKEN, {
  name: 'my-file.txt',
  content: 'This is a file uploaded with now-storage.'
}, { teamId: 'my-awsm-team' });

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.