Keeping the source document¶
By default the uploaded document is deleted after the conversion. You can keep it on the node instead.
Set it up¶
- Add a File or Image field to the content type. Allow the extensions
doc docx odt rtf pptx. - In Manage form display, open the settings of the DOC to HTML widget.
- Choose that field in Source file field.
The tutorial shows these steps for the Article content type.
What happens¶
After a successful conversion the document is moved to the upload directory of the target field, with the field's uri_scheme and file_directory settings and tokens resolved. This means two content types can use two different folders.
The file stays temporary at this point. Its identifier is put in the target field of the form. When the editor saves the node, the file field records the usage and Drupal makes the file permanent. The document and the HTML are stored together.
The life of the file in 2.1.x¶
The rule is that a file is permanent only when a saved entity uses it, and the cron of this module touches only its working folder.
| Case | Where it is | State | Who removes it |
|---|---|---|---|
| Kept and saved | Directory of the source file field | Permanent, in use | Nobody, it is never touched |
| Kept but abandoned (the form was left without saving) | Directory of the source file field | Temporary | The cron of core, after temporary_maximum_age |
| In transit (the upload, the HTML, the discarded images, the LibreOffice profile) | Conversion folder | Temporary | The end of the conversion, or the cron of this module after six hours |
| Inserted image | Image upload directory | Same as the document | Same as the document |
A document that the editor never saves is removed by the cron of core, 6 hours after the upload by default. See How the data flows.
Notes¶
- If the target field accepts several values, the document is added after the existing ones. When the field is full, the document is not saved and the editor sees a warning.
- The target field must not need input that the widget cannot provide, such as a required description or alt text.
- The module never removes a permanent file or a file that is in use. Its cleanup only touches temporary files in its own working folders.
2.0.x
In 2.0.x the source document stays in public://doc_to_html, where it can be opened by URL. The cron and the cleanup after each conversion delete the managed files of that folder. Up to 2.0.1 they delete the documents saved in the source field too, so the node loses its file. Use 2.0.2 or later, which does not touch permanent files or files in use. See Versions.