Support for media folders in the content API
D
Derrickmehaffy
With the upcoming release of Strapi v4.3.0 and Media folders, the content API will not be able to utilize them. For those that believe it would be a good addition to also have folders at the content API level please leave a vote and comment what your use case would be.
Bewar Salah
I was trying to deploy the app to my vm. Mistakenly I removed all files and started over by cloning the app from github. Then I realized that I am not able to get back these files.
Conrad Gellel
This feature is really needed because at the moment it would be impossible for the user to select an already uploaded image when a lot of images have been uploaded already.
J
Jannik
Talking end of 2023 and this basic basic feature is still not supported. Why do all Strapi features feel so beta?
M
Marco Autiero ✅
Jannik: Thanks for reaching out and sharing your feedback. At Strapi, we prioritize development based on community needs and technical feasibility. We keep an iterative approach and, year after year, Strapi is growing more and more in terms of capabilities and adoption. Sometimes, we're forced to redirect our attention on other features, post-poning the futher evolution for some other parts of the software.
To better understand your perspective, could you please share some details about the specific features you're referring to that feel beta? Knowing the use case and desired functionality would help us evaluate its priority and provide a more precise answer.
For example, what specific tasks are you trying to accomplish? Is it impacting your project significantly? Are there any workarounds you've explored in the meantime?
gian Blas
go
Tais993
At my work we're talking about thousands of images, currently they're structured in many many folders.
With the API, we can only upload to that 1 folder..
That removes the whole benefit of using the API, having thousands of images with some the same name, in the same folder, nah.
This would be extremely appreciated, otherwise we'll have to stick with Umbraco.
Ayodeji Alarape
Here's a plugin I developed that could help, It can get folders and files in the folder aswell.
Cameron McBroom
I found clients can get confused having to link/create relations to different images or files when there are multiple galleries throughout the site. I think it is much more intuitive for a non dev to just put their photos into different folders and they will appear in the corresponding galleries.
For now I have just made a simple get by folder id controller like so. Not ideal but works
module.exports = {
getByFolderId: async (ctx, next) => {
try {
const files = await strapi.db.connection
.select('*')
.from('files')
.innerJoin('files_folder_links', 'files.id', 'files_folder_links.file_id')
.where('folder_id', folderId)
ctx.body = files
} catch (err) {
ctx.body = err;
}
}
};
Axel Hultman
This would be a great feature. As others have mentioned, why not provide the options you get in the plugins own methods and add the ability to specify folder. Need to create custom controllers just to adjust this now
Lucas S.
Having the ability to dynamically create folders on upload would make migrations so much easier. Imagine a structure with hundreds of folders organized by a client and we have to keep that same structure on the admin UI. Automation would be a breeze, it is a quality of life feature.
Tobias
Here a solution that uses the upload plugin's own methods:
// Generate folders
async createFolders(order) {
// Create year media folder if not exists
const year = new Date().getFullYear().toString()
let yearFolder = await strapi.query('plugin::upload.folder').findOne({where: {name: year}});
if (!yearFolder) {
await strapi.plugins.upload.services.folder.create({name: year})
yearFolder = await strapi.query('plugin::upload.folder').findOne({where: {name: year}});
}
// Create order media folder
await strapi.plugins.upload.services.folder.create({name: order, parent: yearFolder.id})
return await strapi.query('plugin::upload.folder').findOne({where: {name: order, parent: yearFolder}});
},
// Move files into folder
async moveOrderFilesToFolder(order, folder) {
let update = []
const files = (await strapi.db.query("api::order.order").findOne({
where: { id: order.id },
populate: {
files: true,
}
})).files
if(files !== null) {
for (const file of files) {
update.push(await strapi.plugins.upload.services.upload.updateFileInfo(file.id, {
name: file.name,
alternativeText: file.alternativeText,
caption: order.attributes.order,
folder: folder.id,
folderPath: folder.path
}))
}
return update
}
},
Load More
→