uplo
v0.21.0
Menangani pengunggahan file ke berbagai layanan penyimpanan seperti Amazon S3, Google Cloud, dll. Ini juga mendukung berbagai jenis adaptor ORM, seperti Prisma.
Tambahkan @uplo/node
ke package.json Anda
yarn add @uplo/node
Instal Adaptor (misalnya Prisma)
yarn add @uplo/adapter-prisma dataloader
Instal Layanan (misalnya S3)
yarn add @uplo/service-s3
Tentukan contoh uplo
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'
} ) )
Paket ini tersedia sebagai open source berdasarkan ketentuan Lisensi MIT.