GithubHelp home page GithubHelp logo

storage-wrapper's Introduction

Simple blob storage API

Want to use a super simple API to upload random blobs of data? Here you go!

const pathname = 'test.txt';
const body = 'Hello, world!';
const options = { access: 'public' };
const { url } = await put(pathname, body, options);

Yay! Your url is public and immediately referrable, it's got a random unguessable URL.

How it works

This is an incredibly simple wrapper around the S3 SDK. It's actually hardcoded to use Cloudflare R2, which is basically the same API but way cheaper. But it does require you to have a few env vars defined

AWS_ACCESS_KEY_ID=zzz
AWS_SECRET_ACCESS_KEY=zzz
AWS_ACCOUNT_ID=zzz
AWS_S3_BUCKET_NAME="vercel-test"

Chuck that into a dotenv, and you're golden

Can I pay you more money

If you pay me enough money I'll run a server that exposes this API to you. All I'll do on the backend is have a DB table that has the following mapping

user_id, token_value

I'll bring my own secret_access_key and access_key. I'll use the user_id for the bucket name.

I guess I'll also track your usage so I can bill you.

but is it serverless? on the edge?

yes? no? If you give me enough money I'll replicate across multiple regions by creating multiple buckets. Essentially pick a primary region, write there first, when that's successful, copy the object into your other buckets.

oh, actually if you are already running on the edge in a cloudflare worker, then the default region that a new bucket gets created in would be the caller's region. so I guess we would have to alter the primary region per request, essentially run our own cloudflare worker that first writes to its location then creates a deferred job to replicate to other regions. ok, a bit more complexity, I can see why that might be cool.

nb: after reading the vercel docs super closely, I don't think that's true, I literally think that it's just a single region lol.

storage-wrapper's People

Contributors

stillmatic avatar

Stargazers

Sean avatar

Watchers

 avatar  avatar

Forkers

14h

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.