@@ -15,11 +15,13 @@ Project sample : [adonis-starter-kit](https://github.com/batosai/adonis-starter-
15
15
- [ ] documents thumbnail
16
16
- [x] videos thumbnail
17
17
- [ ] command regenerate
18
- - [ ] adonis-drive/flydrive
18
+ - [x ] adonis-drive/flydrive
19
19
- [ ] jobs queue
20
20
- [ ] edge component
21
21
- [x] serialize
22
22
23
+ ⚠️ Breaking change [ 2.0.0 version] ( https://github.com/batosai/adonis-attachment/blob/main/CHANGELOG.md ) , include [ @adonisjs/drive ] ( https://docs.adonisjs.com/guides/digging-deeper/drive )
24
+
23
25
### File sytem
24
26
25
27
Upload file in public folder.
@@ -42,9 +44,9 @@ Configure differents images sizes and formats
42
44
43
45
Regenerate variantes files
44
46
45
- ### Drive (coming soon)
47
+ ### Drive
46
48
47
- Use drive for private file and cloud services
49
+ Use [ @ adonisjs/ drive] ( https://docs.adonisjs.com/guides/digging-deeper/drive ) for private file and cloud services
48
50
49
51
### Jobs queue (coming soon)
50
52
@@ -55,13 +57,13 @@ Couple with a job queue (recommended, optional)
55
57
Install and configure the package:
56
58
57
59
``` sh
58
- node ace add @jrmc/adonis-attachment
60
+ node ace add @jrmc/adonis-attachment@beta
59
61
```
60
62
61
63
Or:
62
64
63
65
``` sh
64
- npm i @jrmc/adonis-attachment
66
+ npm i @jrmc/adonis-attachment@beta
65
67
node ace configure @jrmc/adonis-attachment
66
68
```
67
69
@@ -163,23 +165,41 @@ class User extends BaseModel {
163
165
## URLs
164
166
165
167
``` ts
166
- user .avatar .getUrl ()
167
- user .avatar .getUrl (' thumbnail' )
168
+ await user .avatar .getUrl ()
169
+ await user .avatar .getUrl (' thumbnail' )
168
170
// or await user.avatar.getVariant('thumbnail').getUrl()
171
+
172
+ await user .avatar .getSignedUrl ()
173
+ await user .avatar .getSignedUrl (' thumbnail' )
174
+ // or await user.avatar.getVariant('thumbnail').getSignedUrl()
169
175
```
170
176
171
177
``` edge
172
- <img src="{{ user.avatar.getUrl('thumbnail') }}" loading="lazy" alt="" />
178
+ <img src="{{ await user.avatar.getUrl('thumbnail') }}" loading="lazy" alt="" />
179
+
180
+ <img src="{{ await user.avatar.getSignedUrl() }}" loading="lazy" alt="" />
181
+ <img src="{{ await user.avatar.getSignedUrl({
182
+ expiresIn: '30 mins',
183
+ }) }}" loading="lazy" alt="" />
184
+
185
+ <img src="{{ await user.avatar.getSignedUrl('thumbnail') }}" loading="lazy" alt="" />
186
+ <img src="{{ await user.avatar.getSignedUrl('thumbnail', {
187
+ expiresIn: '30 mins',
188
+ }) }}" loading="lazy" alt="" />
173
189
```
174
190
191
+ getSignedUrl options params accepts ` expiresIn ` , ` contentType ` et ` contentDisposition ` . [ More informations] ( https://flydrive.dev/docs/disk_api#getsignedurl )
192
+
193
+
175
194
### by serialize
176
195
177
196
``` ts
178
- user .avatar .toJSON ()
197
+ await user .avatar .toJSON ()
179
198
```
180
199
181
200
``` html
182
- <img :src =" user.avatar.thumbnail" loading =" lazy" alt =" " />
201
+ <img :src =" user.avatar.thumbnail.url" loading =" lazy" alt =" " />
202
+ <img :src =" user.avatar.thumbnail.signedUrl" loading =" lazy" alt =" " />
183
203
```
184
204
185
205
## Configuration
@@ -192,7 +212,6 @@ import app from '@adonisjs/core/services/app'
192
212
import sharp from ' sharp'
193
213
194
214
export default defineConfig ({
195
- basePath: app .publicPath (),
196
215
converters: [
197
216
{
198
217
key: ' thumbnail' ,
@@ -252,6 +271,7 @@ npm install sharp
252
271
```
253
272
254
273
Variants thumbnail videos are generate by [ fluent-ffmpeg] ( https://www.npmjs.com/package/fluent-ffmpeg )
274
+
255
275
By default, image format is PNG and size is video size. ` options ` attribute use image_converter (and sharp)
256
276
257
277
``` sh
0 commit comments