Add attchments using CSV import
Attachments can be added when creating documents from “Files tab”, i want to do the same thing using a CSV file so i wonder what should I add as a property that refers to attachments in the CSV file. I'm able to add the Main File using “file:content” property , I've tried to add “files:file:content” but it's not working. Any idea about this ?
Short answer: after a closer look to the CSV Import bundle, in the CSVImporterWork class, there doesn't seem to have any way to handle another blob proeprty than the "file:content" one or, at least, one which is not part of a list or complex type property and still named "content".
Explanation (but I might be wrong): "files:files" is an array property, so should be handled as such in the CSV file. So, it SHOULD be something like: Header: files:files In the CSV line: "[{\"filename\":\"name for file 1\",\"file\":\"file1.pdf\"},{\"filename\":\"name for file 2\",\"file\":\"file2.docx\"}]"
This is how it SHOULD be, from my understanding on how it works. As it is an array property, it would be handled by the "fieldType.isListType()" part, and then handled as a simple array, and not an array which could contain blobs to handle. I tried the line I give before and I get an exception:
java.lang.ClassCastException: org.codehaus.jackson.node.TextNode cannot be cast to org.codehaus.jackson.node.ObjectNode
at org.nuxeo.ecm.automation.core.util.ComplexTypeJSONDecoder.decode(ComplexTypeJSONDecoder.java:121)
It means that the program tries to use a string as an object. So it does evaluate the \"file\":\"file1.pdf\" as if it would be for a string property, not a blob.
As it is right now, I'm not sure the CSV importer can handle your case, except by modifying it.