Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
@jrmc/adonis-attachment
Advanced tools
Turn any field on your Lucid model to an attachment data type
This package is currently development and will replace attachment-advanced for AdonisJS 6.
Project sample : adonis-starter-kit
⚠️ Breaking change version 2, include @adonisjs/drive
Install and configure the package:
node ace add @jrmc/adonis-attachment
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...)
FAQs
Turn any field on your Lucid model to an attachment data type
The npm package @jrmc/adonis-attachment receives a total of 88 weekly downloads. As such, @jrmc/adonis-attachment popularity was classified as not popular.
We found that @jrmc/adonis-attachment demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.