API
Version 7.x > API > Import Utility - How do I import files as part of my document type? View modes: 
User avatar
Member
Member
mosgath - 9/20/2012 8:31:39 AM
   
Import Utility - How do I import files as part of my document type?
I am attempting to import an Excel file into a custom document. Two of my fields are of type file. In my spreadsheet, I use the #{URL} format for the fields. However, when I proceed to import the files, I get the following error:

An error occured on import: [DataConnection.HandleError]: Query: INSERT INTO nof_File ([FileName], [FileDescription], [FileAttachment], [FileTeaserImage] ) VALUES ( @FileName, @FileDescription, @FileAttachment, @FileTeaserImage); SELECT SCOPE_IDENTITY() AS [FileID] : caused exception: Conversion failed when converting from a character string to uniqueidentifier.

I think based off what I read that it is trying to take the contents of the file and import them into the FileAttachment and FileTeaserImage fields instead of generating a file for them.

How do I create an import where I can automatically import the files for those records:

Document Type:
FileID int
FileName Text (100)
FileDescription LongText
FileAttachment File
FileTeaserImage File

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 9/21/2012 6:26:26 AM
   
RE:Import Utility - How do I import files as part of my document type?
Hi,

could you please confirm following?

1. In your source data you have the source field for example Path which contains path to the image. This could be for example:

A: C:\picture.jpg
B: \\test\shared\obrazek.jpg
C: http://www.seznam.cz/picture.jpg


2. Then in the step where you map source and destinatino data you used syntax:

#<file>{%Path%}

Path is a name of your source image path column.

Thank you for clarification.

Best regards,
Ivana Tomanickova

User avatar
Member
Member
mosgath - 9/21/2012 7:45:25 AM
   
RE:Import Utility - How do I import files as part of my document type?
As suggested, I updated the Source Field or Expression column to:
#<file>{%Enlarged%}
#<file>{%Thumbnail%}

The same error comes back:

An error occured on import: [DataConnection.HandleError]: Query: INSERT INTO nof_File ([FileName], [FileDescription], [FileAttachment], [FileTeaserImage] ) VALUES ( @FileName, @FileDescription, @FileAttachment, @FileTeaserImage); SELECT SCOPE_IDENTITY() AS [FileID] : caused exception: Conversion failed when converting from a character string to uniqueidentifier.


In the Check the Data window, under the field FileAttachment and FileTeaserImage, it shows System.Byte[]. These are the only two fields in the SQL Server table that are unique identifiers. They are FileTeaserImage and FileAttachment. In the CMS they are defined as type file.

The fields in the spreadsheet contain the proper UNC naming. I can click the links in the spreadsheet and it opens the files correctly. I also tried fields with a URL format, but got the same result.

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 9/25/2012 11:57:15 AM
   
RE:Import Utility - How do I import files as part of my document type?
Hi,

import toolkit is no able to handle images with path starting with space, i.e. the column with path cannot start with the space. Could you please confirm that it is not problem in your configuration data?

If no, could you please share the data you are trying to import? You can post them here so that I could copy them to the sheet.

Thank you.

Ivana Tomanickova

User avatar
Guest
Accepted solutionAccepted solution
kentico_ivanat - 9/26/2012 7:38:08 AM
   
RE:Import Utility - How do I import files as part of my document type?
Hi again,

finally the problem is that #<file>{%fieldName%} syntax works in AttachmentBinary column only.

I have created a requirment to add this functionality also to the particular document fields. So that guid would be stored in the column and binary data and information about file would be uploaded to the CMS_Attachment table.

I am sorry for inconvenience.

Best regards,
Ivana Tomanickova

User avatar
Member
Member
mosgath - 9/28/2012 1:41:29 PM
   
RE:Import Utility - How do I import files as part of my document type?
Thanks.