cancel
Showing results for 
Search instead for 
Did you mean: 

Add attchments using CSV import

ITShine_
Star Contributor
Star Contributor

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 ?

6 REPLIES 6

Greg_Drayon
Star Contributor
Star Contributor

I'm not sure to understand your question, but the "files" schema does not work like the "file" schema. "file" does have two attributes named filename and content, but files does not. It contains a list of items names files, with each item having two attributes

ITShine_
Star Contributor
Star Contributor

Thank you [Greg Drayon](https

Greg_Drayon
Star Contributor
Star Contributor

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.

ITShine_
Star Contributor
Star Contributor

Okay, thank you so much [Greg Drayon](https

Florent_Guillau
World-Class Innovator
World-Class Innovator

Note that file

Greg_Drayon
Star Contributor
Star Contributor

Thank you for the update. My knowledge might be a little bit outdated.

Getting started

Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.