URL 未保存在文件字段对象中

URL not saved in File Field object

我使用 File Field 上传文件,它工作正常,但文件 URL 未保存在数据库中。

文件对象

benifitsFile
Object:filename:
"srrfnKNvcQ1zTOup.pdf"
size:878742
mimetype:"application/pdf"

我必须定义存储路径并添加文件类型。

var Storagepath = new keystone.Storage({
  adapter: keystone.Storage.Adapters.FS,
  fs: {
    path: '/public/uploads',
        publicPath: '/public/uploads/',
  },
});

Course.add({
  title: { type: String, required: true, initial: true},
  headerimage: { type: Types.CloudinaryImage,label:'Header Image' },
  benifitsFile: { type: Types.File, storage: Storagepath ,label:'Upload features & benifits file'},
  questions: { type: Types.Relationship, ref: 'Question', index: true,many:true }
});

谢谢

终于找到解决方法了

var Storagepath = new keystone.Storage({
  adapter: keystone.Storage.Adapters.FS,
  fs: {
    path: keystone.expandPath('./public/uploads'),
    publicPath: './public/uploads',
  },
  schema: {
    size: true,
    mimetype: true,
    path: true,
    originalname: true,
    url: true,
    },
});