CMS: Uploading from CK editors
I would like to be able to copy-paste an image or file directly in the Editor and it should be uploaded the server.
genesys-pgr/genesys-server!607 provides API endpoints to upload files related to ActivityPost
and Article
to the server (the CMS article/activityPost must be stored!)
When the article/post is removed, this folder and its contents are also removed.
We have similar functionality for our Markdown editors:
const apiUploadFile = createPureApiCaller(RepositoryService.uploadFile);
export const uploadMarkdownAttachment = (file: File) => (dispatch, getState) => {
const metadata: RepositoryFile = new RepositoryFile();
const dummy: string = UUIDv4().replace(/-/g, '');
metadata.originalFilename = `${dummy}_${file.name}`;
metadata.contentType = file.type;
console.log(`Uploading Markdown`, metadata);
return dispatch(apiUploadFile('/content/markdown', file, metadata))
.then((repoFile: RepositoryFile) => {
return repoFile;
}).catch((error) => {
log('Upload error', error);
});
};
Please add a onPaste
event handler that will upload the image/file to the server and inject the relevant HTML to CK editor.