Skip to content

Handle file uploads to different storage services like Amazon S3, Google Cloud or etc. It also supports different type of ORM adapters, like Prisma.

License

Notifications You must be signed in to change notification settings

jpalumickas/uplo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Oct 29, 2024
cded181 · Oct 29, 2024
May 4, 2021
Mar 17, 2024
Oct 29, 2024
Oct 23, 2024
Oct 29, 2024
Oct 29, 2024
Mar 27, 2023
Sep 16, 2024
Dec 8, 2022
Jan 23, 2023
Mar 17, 2024
Oct 29, 2024
Oct 29, 2024
Oct 29, 2024
Sep 7, 2023
Mar 17, 2024

Repository files navigation

Uplo

Handle file uploads to various storage services like Amazon S3, Google Cloud or etc. It also supports various type of ORM adapters, like Prisma.

Features

  • TypeScript ready
  • Direct uploads
  • Supports multiple services
  • Multiple ORM adapters
  • File analyzers

Getting started

Add @uplo/node to your package.json

yarn add @uplo/node

Install Adapter (for example Prisma)

yarn add @uplo/adapter-prisma dataloader

Install Service (for example S3)

yarn add @uplo/service-s3

Define uplo instance

import Uplo from '@uplo/node';
import PrismaAdapter from '@uplo/adapter-prisma';
import GCSService from '@uplo/service-gcs';

const config = {
  privateKey: process.env.APPLICATION_SECRET, // Used to sign direct upload keys
  signedIdExpiresIn: 60 * 60, // Time how long a Signed ID is valid
};

const uplo = Uplo({
  config,
  adapter: new PrismaAdapter({ prisma }),
  services: {
    s3: S3Service({
      isPublic: false,
      region: process.env.AWS_REGION,
      bucket: process.env.AWS_BUCKET,
      accessKeyId: '*****',
      secretAccessKey: '*****',
    }),
  },
  attachments: {
    user: {
      avatar: true, // pass true to use default options
    },
    post: {
      images: { multiple: true }
    }
  },
});

const attachment = await uplo.attachments.user(123).avatar.attachFile(await blobFileInput({
  path: '/home/images/image.png'
}))

License

The package is available as open source under the terms of the MIT License.