Support docx images
Base64 images should be reconstructed and uploaded to file storage and then their reference inside the document should be replaced with their corresponding URL
.
- Update to xsweet microservice 2.0.0
- Modify
callbackURL
attribute to${url/api/xsweet}
https://gitlab.coko.foundation/ketida/ketida/-/blob/master/packages/server/api/useCases/services.js#L323 - Change the
url
to${serverUrl}/api/v1/async/DOCXToHTML
https://gitlab.coko.foundation/ketida/ketida/-/blob/master/packages/server/api/useCases/services.js#L328 - Change
bookComponentId
toobjectId
https://gitlab.coko.foundation/ketida/ketida/-/blob/master/packages/server/api/rest/controllers.js#L57
Implement the following logic here https://gitlab.coko.foundation/ketida/ketida/-/blob/master/packages/server/api/rest/controllers.js#L87 :
- From the provided
objectId
(represents the id of a book component) find the book id - Scan the
convertedContent
forimg
tags usingcheerio
library - If
img
exists then it will be encoded in base64 format e.g. thesrc
attribute will be something like that
src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QB0RXhpZgAATU0AKgAAAAgABAEaAAUAAAABAAAAPgEbAAUAAAABAAAARgEoAAMAAAABAAIAAIdpAAQAAAABAAAATgAAAAAAAABIAAAAAQAAAEgAAAABAAKgAgAEAAAAAQAAC9CgAwAEAAAAAQAAD8AAAAAA/+0AOFBob3Rvc2hvcCAzLjAAOEJJTQQEAAAAAAAAOEJJTQQlAAAAAAAQ1B2M2Y8AsgTpgAmY7PhCfv/src=\"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QB0RXhpZgAATU0AKgAAAAgABAEaAAUAAAABAAAAPgEbAAUAAAABAAAARgEoAAMAAAABAAIAAIdpAAQAAAABAAAATgAAAAAAAABIAAAAAQAAAEgAAAABAAKgAgAEAAAAAQAAC9CgAwAEAAAAAQAAD8AAAAAA/+0AOFBob3Rvc2hvcCAzLjAAOEJJTQQEAAAAAAAAOEJJTQQlAAAAAAAQ1B2M2Y8AsgTpgAmY7PhCfv
- Convert that to an actual file in a temp location
- Upload it to file server
- Create a file representation of the uploaded image
- Replace its src with with the appropriate url of the uploaded file
- Add
data-fileid
attribute to the correspondingimg
tag which will point to the actual created file id