Skip to content

General configuration

Attachment configuration is located in the config/auditing.ts file. By default, the file looks like this:

typescript
import { defineConfig } from '@jrmc/adonis-attachment'

export default defineConfig({
  converters: [
    {
      key: 'thumbnail',
      converter: () => import('@jrmc/adonis-attachment/converters/image_converter'),
      options: {
        resize: 300,
      }
    }
  ]
})

converters

OPTIONS:DESCRIPTIONS:
keyVariant name
converterClass for generate variant
optionsOptions converter

preComputeUrl (optional, default false)

enable the preComputeUrl flag to pre compute the URLs after SELECT queries.

typescript
export default defineConfig({
  preComputeUrl: true, 
  converters: [
    // ...
  ]
})

meta (optional, default true)

you can set the default meta generation or not

typescript
export default defineConfig({
  meta: false, 
  converters: [
    // ...
  ]
})

rename (optional, default true)

You can define by default if the files are renamed or not.

typescript
export default defineConfig({
  rename: false, 
  converters: [
    // ...
  ]
})

bin (optional)

You may set the ffmpeg and ffprobe binary paths manually:

typescript
export default defineConfig({
  bin: { 
    ffmpegPath: 'ffmpeg_path', // the full path of the binary
    ffprobePath: 'ffprobe_path', // the full path of the binary
    pdftocairoBasePath: 'base_dir_path' // the path of the directory containing the binary
    libreofficePaths: [
      'libreoffice_path', // the full path of the binary
    ] // Array of paths to LibreOffice binary executables.
  },
  converters: [
    // ...
  ]
})
OPSTIONSDESCRIPTIONS:
ffmpegPathArgument path is a string with the full path to the ffmpeg binary
ffprobePathArgument path is a string with the full path to the ffprobe binary
pdftocairoBasePathArgument path is a string with the path of the directory to the pdftocairo binary
libreofficePathsArray of paths to LibreOffice binary executables

sample

download ffmpeg and ffprobe binary in /bin. Add execution right.

sh
cd bin
chmod +x ffmpeg
chmod +x ffprobe
typescript
import app from '@adonisjs/core/services/app'
import { defineConfig } from '@jrmc/adonis-attachment'

export default defineConfig({
  bin: { 
    ffmpegPath: app.makePath('bin/ffmpeg'),
    ffprobePath: app.makePath('bin/ffprobe'),
  },
  converters: [
    // ...
  ]
})