Hello,
I am trying to update the urls of media library files but the update endpoint doesn’t seem to update the url, only the name and alt text.
// Function to update Strapi with the new file URL
async function updateStrapiFile(fileId, newURL) {
console.log('new url ', newURL)
const newFileData = {
url: newURL,
name: 'test',
alternativeText: 'test',
};
const form = new FormData();
form.append('fileInfo', JSON.stringify(newFileData));
try {
const response = await axios.post(`${strapiURL}/api/upload?id=${fileId}`, form, {
headers: {
'Authorization': `Bearer ${strapiToken}`,
},
family: 4
});
console.log(response.data);
console.log(`Updated Strapi for file ID: ${fileId}`);
} catch (error) {
console.error(`Error updating file ${fileId} in Strapi:`, error);
}
}
Since the url seems to be readOnly what would be the best approach to get this to work. Last resort would of course be go to straight to the database and make the changes but I am trying to avoid that.
This topic has been created from a Discord post (1293584463455846495) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord