feathers-mongoose-casl
Version 2.1.2
Version 2.1.2
  • feathers-mongoose-casl
  • Docs
    • Migrating
    • START A NEW PROJECT
      • Generate a new project.
      • install feathers-mongoose-casl
      • feathers-logger
      • Update config
      • Add mongoose
      • Email service
      • App hooks
      • Import required services
      • Verify user and filter user fields
      • Swagger, Logger, BodyParser
      • Email templates
      • public HTML
      • Run the server
      • Create you first user
      • vs code snippet extension
      • Test Login
      • Dashboard
      • Create a new Service with casl&Dashboard
      • Posts Postman snippet
      • Add Admin role
      • Done!
    • Advanced
      • Security - eslint-plugin-security
      • Security - rate limiting
      • Development tools
    • Guides
      • Throw errors
      • Auth Flow
      • Authentication
      • Authouriztion
      • /me
      • Rules Cache
      • Create a new service
      • Custom service validtor client data
      • validators
        • Example of use
        • Types
        • Mongoose schema
      • Default value
      • $Populate
      • Upload service
      • Upload files
        • Create upload service
        • Sign File After Populate
        • Storage support
          • Google-cloud
      • Error
      • feathers Client examples
      • Dashboard
        • Dashboard Config
          • Field configuration
          • doc Layout
          • custom Fields
            • customElements
        • Online dashboard
        • Add to your react app
      • customized feathers-mongoose-casl/services
      • Redis - in progress
      • S3
      • Postman
      • Swagger
      • debug
    • Production
      • ENV
    • Feathers wiki
      • Good links
    • utils
      • send email example
      • Async For Each
      • Create heroku server
      • pick
      • vs code snippet extension
      • Persist user request
    • Ecosystem
    • TODO
    • Versions updates
Powered by GitBook
On this page

Was this helpful?

  1. Docs
  2. Guides
  3. Upload files

Sign File After Populate

When a collection point to other collection of private files and you want to populate the file and get a sign file url, you need to add in the collection hook that handle the sign of the file after the request example of use: ------------------------------

let say post is point to admin that point to user that point to profile that point to logo logo is collection of private files the request : -----------------------------

app.service('posts').find({query:{
  $populate: {
    path: 'admin',
    populate: {
      path: 'user',
      populate: {
        path: 'profile',
        populate: {
          path: 'logo'
        }
      }
    }
  }
}})

in the posts.hooks.js:

const {hooks} = require('feathers-mongoose-casl');
const {singFileAfterPopulate} = hooks;

module.exports = {
  after: {
    find: [
      singFileAfterPopulate({
        path: 'admin.user.profile.logo',
        fileKeyName: 'file',
        singUrlKeyName:'file'
      })
    ],
    get: [],
    create: [],
    update: [],
    patch: [],
    remove: []
  }
  ....
  }

when you populate a file field and you use select, to sign file with singFileAfterPopulate you need this fields are required ['_id','storage','fileId',[fileKeyName]]

PreviousCreate upload serviceNextStorage support

Last updated 5 years ago

Was this helpful?