Intevel/nuxt-directus

support to upload files through via this module

Closed this issue · 1 comments

wrapper for Directus SDK directus.files.createOne

Have you any function for this SDK function?

Thanks.

If you are referring to the nuxt-directus-next module then it is based on the NEW SDK, so syntax is a bit different, and yes we do have a function to directly upload files via:

const { uploadFiles } = useDirectusFiles()

const formData = new FormData()
formData.append('file_1_property', 'Value')
formData.append('file', raw_file)
formData.append('file_2_property', 'Value')
formData.append('file', raw_file_2)

const result = await uploadFiles(formData)

or via link:

const { importFile } = useDirectusFiles()

const result = await importFile(file_url, file_object)

Be aware that nuxt-directus-next is still being finalized and not yet fully stable, so if you do find any issue while implementing the code above feel free to reopen this issue by providing a reproduction link to a git repo or stackblitz.