Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var keystone = require('keystone');
var Types = keystone.Field.Types;
/**
* Image Upload Model
* ===========
* A database model for uploading images to the local file system
*/
var ImageUpload = new keystone.List('ImageUpload');
var myStorage = new keystone.Storage({
adapter: keystone.Storage.Adapters.FS,
fs: {
path: keystone.expandPath('./public/uploads/images'), // required; path where the files should be stored
publicPath: '/public/uploads/images', // path where files will be served
//File paths for Docker container.
//path: keystone.expandPath('../public/uploads/images'), // required; path where the files should be stored
//publicPath: '../public/uploads/images', // path where files will be served
}
});
ImageUpload.add({
//name: { type: Types.Key, required: true, index: true }, //requiring name breaks image upload.
name: { type: Types.Key, index: true},
image: {
//type: Types.LocalFile,
var keystone = require('keystone');
var Types = keystone.Field.Types;
// Create a new Keystone list called Recipe
var Recipe = new keystone.List('Recipe', {
autokey: { path: 'slug', from: 'name', unique: true },
defaultSort: '-createdAt',
});
// Adding the option to add an image to our Recipe from
var recipeImgStorage = new keystone.Storage({
adapter: keystone.Storage.Adapters.FS,
fs: {
// required; path where the files should be stored
path: keystone.expandPath('server/public/img'),
generateFilename: function (file, index) {
return file.originalname;
},
whenExists: 'error',
// path where files will be served
publicPath: '/public/img',
},
});
// Finally we are gonna add the fields for our Recipe
Recipe.add({
name: {
var keystone = require('keystone');
var Types = keystone.Field.Types;
/**
* File Upload Model
* ===========
* A database model for uploading images to the local file system
*/
var FileUpload = new keystone.List('FileUpload');
var myStorage = new keystone.Storage({
adapter: keystone.Storage.Adapters.FS,
fs: {
path: keystone.expandPath('./public/uploads/files'), // required; path where the files should be stored
publicPath: '/public/uploads/files', // path where files will be served
//File paths for Docker container.
//path: keystone.expandPath('../public/uploads/images'), // required; path where the files should be stored
//publicPath: '../public/uploads/images', // path where files will be served
}
});
FileUpload.add({
//name: { type: Types.Key, required: true, index: true }, //requiring name breaks image upload.
name: { type: Types.Key, index: true},
file: {
//type: Types.LocalFile,
var keystone = require('keystone');
var Types = keystone.Field.Types;
/**
* File Upload Model
* ===========
* A database model for uploading images to the local file system
*/
var ExampleFile = new keystone.List('ExampleFile');
var myStorage = new keystone.Storage({
adapter: keystone.Storage.Adapters.FS,
fs: {
path: keystone.expandPath('./uploads'), // required; path where the files should be stored
publicPath: '/public/uploads', // path where files will be served
}
});
ExampleFile.add({
//name: { type: Types.Key, required: true, index: true }, //requiring name breaks image upload.
name: { type: Types.Key, index: true},
file: {
//type: Types.LocalFile,
type: Types.File,
storage: myStorage
},
var keystone = require('keystone');
var transform = require('model-transform');
var Types = keystone.Field.Types;
var File = new keystone.List('File');
var storage = new keystone.Storage({
adapter: keystone.Storage.Adapters.FS,
fs: {
path: keystone.expandPath('./uploads'),
publicPath: '/public/uploads/',
},
schema: {
mimetype: false,
size: false,
originalname: true,
},
});
File.add({
name: { type: String },
file: { type: Types.File, storage: storage, required: true, initial: true },
});
const keystone = require('keystone')
const path = require('path')
const ReportLevelEnum = require('./enum/ReportLevelEnum')
const Types = keystone.Field.Types
const ReportImageStorage = new keystone.Storage({
adapter: keystone.Storage.Adapters.FS,
fs: {
path: path.join(__dirname, '../../static/images/report'),
publicPath: '/static/images/report'
}
})
const Report = new keystone.List('Report', {
defaultSort: 'createdAt',
map: { name: 'topic' }
})
Report.add({
topic: { type: String, label: 'หัวข้อ' },
targetURL: { type: String },
description: { type: String },
var keystone = require('keystone');
var transform = require('model-transform');
var config = require('/opt/cocorico/api-web/config.json');
var Types = keystone.Field.Types;
var Media = new keystone.List('Media', {
autokey: { path: 'slug', from: 'title', unique: true },
map: { name: 'title' },
track: { createdAt: true, updatedAt: true },
});
var storage = new keystone.Storage({
adapter: keystone.Storage.Adapters.FS,
fs: {
path: keystone.expandPath('../../app/public/'+ config.uploadDir),
publicPath: '/' + config.uploadDir,
},
});
Media.add({
title: { type: String, required: true },
file: {
type: Types.File,
storage: storage,
allowedTypes: [
'image/jpeg',
'image/png',
'image/svg+xml',