šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Sign inDemoInstall
Socket

@jrmc/adonis-attachment

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jrmc/adonis-attachment

Turn any field on your Lucid model to an attachment data type

3.2.3
latest
Source
npm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
Ā 
Created
Source

AdonisJS attachment

This package is currently development and will replace attachment-advanced for AdonisJS 6.

Project sample : adonis-starter-kit

View documentation

ChangeLog

Discord

āš ļø Breaking change version 2, include @adonisjs/drive

Roadmap

  • attachment file by file system
  • attachment file by buffer
  • attachment file by path
  • attachment file by url
  • attachment file by stream
  • save meta data
  • variantes
    • images
    • documents thumbnail
    • videos thumbnail
  • command regenerate
  • command make:convert
  • adonis-drive/flydrive
  • jobs queue
  • serialize

Setup

Install and configure the package:

node ace add @jrmc/adonis-attachment

Sample

Simple upload file

// app/models/user.ts
import { BaseModel } from '@adonisjs/lucid/orm'
import { compose } from '@adonisjs/core/helpers'
import { attachment, Attachmentable } from '@jrmc/adonis-attachment'
import type { Attachment } from '@jrmc/adonis-attachment/types/attachment'

class User extends compose(BaseModel, Attachmentable) {
  @attachment()
  declare avatar: Attachment
}
// app/controllers/users_controller.ts
import { attachmentManager } from '@jrmc/adonis-attachment'

class UsersController {
  public store({ request }: HttpContext) {
    const avatar = request.file('avatar')!
    const user = new User()

    user.avatar = await attachmentManager.createFromFile(avatar)
    await user.save()
  }
}
<img src="{{ await user.avatar.getUrl() }}" loading="lazy" alt="" />

Read documentation for advanced usage(thumbnail video/pdf/doc, create from buffer/base64...)

Keywords

adonisjs

FAQs

Package last updated on 29 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts