postgraphile-plugin-upload-field
Upload fields in PostGraphile
Requires
graphql-upload@^10.0.0
Usage
const fs = ;const path = ;const express = ;const postgraphile = ;const PostGraphileUploadFieldPlugin = ;const graphqlUploadExpress = ; const app = ; const UPLOAD_DIR_NAME = 'uploads'; // Serve uploads as static resourcesapp; // Attach multipart request handling middlewareapp; app; app; { const filename mimetype encoding createReadStream = upload; const stream = ; // Save file to the local filesystem const id filepath = await ; // Return metadata to save it to Postgres return filepath;} { const timestamp = ; const id = `_`; const filepath = path; const fsPath = path; return stream ;}
Examples
See https://github.com/mattbretl/postgraphile-upload-example/ for an example implementation.