Is it possible to create a subfolder within an asset volume via GraphQL? If yes, can you point me in the right direction?
I just found mutations for file uploading, but nothing for folder creation.
Thanks!
Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. It only takes a minute to sign up.
Sign up to join this communityIs it possible to create a subfolder within an asset volume via GraphQL? If yes, can you point me in the right direction?
I just found mutations for file uploading, but nothing for folder creation.
Thanks!
Currently, there’s no direct way of doing this. You can pass an existing folder ID but you can’t create folders on the fly.
However, you can create folders via an asset field (with dynamic path) attached to an entry type so there is an option that could work if you really need this done.
Create a section/entry type that has two fields, an Asset field with a dynamic path set to {folderPath}
and a plain text one called folderPath
.
It would then happen in three steps:
ID
backID
and set folderPath
to whatever path you need, save and get its id
back. This would create a folder and move your asset to it.id
.I know it’s not straight forward but if you really need to make it work, this would do the trick.