Coder Social home page Coder Social logo

blobs.rida.dev's Introduction

Vercel Blob Storage

This project allows you to easily publicly store blobs for usage in CI/CD pipelines, while upload functionality remains protected to the adjacent database owner.

Installation / Setup

  1. Fork this repository or clone it using git clone [email protected]:ridafkih/blobs.rida.dev.git and then upload it to your own GitHub.
  2. Log into vercel.com, and on the dashboard click "Add new", project, and select your iteration of the project and initialize the project.
  3. Navigate to the project dashboard.
  4. Click on the "Storage" tab on the project navigator.
  5. Click "Connet Store," and create a PostgreSQL Database and a Blob Store.
  6. Run vercel link on your local project.
  7. Run vercel env pull .env.development.local on your local project.

Configuration Notes

Database Table Creation

There is two tables in the database. keys stores credential information and whether or not the credentials are activated and permitted to faciliate blob uploads. manifests stores arbitrary JSON information.

CREATE EXTENSION IF NOT EXISTS "uuid-ossp";

CREATE TABLE keys (
    id TEXT NOT NULL DEFAULT uuid_generate_v4(),
    hash VARCHAR(255) NOT NULL,
    activated BOOLEAN NOT NULL DEFAULT FALSE,
    PRIMARY KEY (id)
);

CREATE TABLE IF NOT EXISTS manifests (
  destination text PRIMARY KEY,
  body jsonb NOT NULL
);

Enabling Keys

You can run an UPDATE query against this database citing a speciic UUID which you use to enable. This will allow the key associated with this id to facilitate uploads to storage.

UPDATE keys
SET activated = TRUE
WHERE id = '';

Endpoints

/register

The registration endpoint will return an identifier and an API key.

{
  "id": "5d134356-03fc-4621-8ea9-cd49d05921ce",
  "authorization": "2gPeMBO35HVYUHbOJn2fU1GEN+LtLPwIIsD8X7zybSo="
}

/artifacts/:path*

The path and filename are designated in the URL, and it returns the url, pathname, contentType, and contentDisposition of the uploaded blob. Anyone with this URL will be able to access the file.

Two headers are required for this API request, x-id should contain the value of id field and Authorization should contain the value of the authorization field. These are both sourced from the response body of /register.

{
  "url": "https://ngyiwepqpnnt9hxj.public.blob.vercel-storage.com/artifacts/index-vhtb5fSrYzV9JlkY1rwETPvhQEXZuW.png",
  "pathname": "artifacts/index.png",
  "contentType": "image/png",
  "contentDisposition": "attachment; filename=\"index.png\""
}

manifests/upload/:path*

manifests/:path*

Authentication

You must set the activated to TRUE should you want to enable a set of credentials to upload to storage, otherwise a 403 will be returned.

blobs.rida.dev's People

Contributors

ridafkih avatar

Watchers

 avatar

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.