text: import Joi from 'joi'
  import UploadFileService from '@/file-upload-handlers/services/UploadFileService'
  
  export default ({ persistenceProvider, StorageProvider, fileUploadHandlerConfig }) => {
    const handler = async (request, h) => {
      return UploadFileService({
        persistenceProvider,
        StorageProvider,
        tempStorageRootPath: fileUploadHandlerConfig.tempStorageRootPath,
        mimeTypes: fileUploadHandlerConfig.mimeTypes,
        deduplication: fileUploadHandlerConfig.deduplication,
        session: request.params.id,
        file: request.payload.file
      })
    }
  
    const config = {
      description: 'Uploads a file to an upload session',
      validate: {
        params: {
          id: Joi.string().required()
        }
      },
      plugins: {
        ...fileUploadHandlerConfig.porgAuth && { 'porg-auth': fileUploadHandlerConfig.porgAuth }
      },
      payload: {
        output: 'stream',
        parse: true,
        allow: 'multipart/form-data',
        ...fileUploadHandlerConfig.payload && { ...fileUploadHandlerConfig.payload }
      }
    }
  
    return {
      handler,
      config
    }
  }
  