You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Why this feature is required (specific use-cases will be appreciated)?
Sometimes you want to set disk/folder options for an attachment on the fly. For example, here I'm setting the folder option based on key, refId & entity
In this case the folder defaults to the one specified on the @attachment decorator in my Media model.
Have you tried any other work arounds?
Yes, I tried Attachment.fromFile(file).setOptions({ folder }).save() which uploads to the correct folder but I could not retrieve the correct path in order to persist it in the DB.
Are you willing to work on it with little guidance?
Yes, of course. Happy to take this on 😊
The text was updated successfully, but these errors were encountered:
You can get it to work by defining the folder path as part of the name of the attachment.
import{cuid}from'@ioc:Adonis/Core/Helpers'constfolder=`${Env.get('NODE_ENV')}/${entity}/${refId}/${key}`constname=`${folder}/${cuid()}.${file.extname}`Attachment.fromFile(file,{ name })
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Why this feature is required (specific use-cases will be appreciated)?
Sometimes you want to set disk/folder options for an attachment on the fly. For example, here I'm setting the folder option based on
key
,refId
&entity
In this case the folder defaults to the one specified on the @attachment decorator in my Media model.
Have you tried any other work arounds?
Yes, I tried
Attachment.fromFile(file).setOptions({ folder }).save()
which uploads to the correct folder but I could not retrieve the correct path in order to persist it in the DB.Are you willing to work on it with little guidance?
Yes, of course. Happy to take this on 😊
The text was updated successfully, but these errors were encountered: