# IntegrationKit import of media fails with exception

**URL:** <https://forum.litium.com/t/integrationkit-import-of-media-fails-with-exception/368>\
**Category:** Questions\
**Tags:** litium-7\
**Created:** [November 16, 2018, 8:48am UTC](https://forum.litium.com/t/integrationkit-import-of-media-fails-with-exception/368 "2018-11-16T08:48:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![StephenM](https://avatars.discourse-cdn.com/v4/letter/s/4da419/32.png) [@StephenM](https://forum.litium.com/u/StephenM)\
**Post date:** [November 16, 2018, 8:48am UTC](https://forum.litium.com/t/integrationkit-import-of-media-fails-with-exception/368/1 "2018-11-16T08:48:33Z")

</div>

I am running an importer using IntegrationKit and I am receiving an error importing an jpg image. It is not a particularly exceptional image being relatively small at only 722kb although it does have a somewhat long name (100+ characters). The error is as follows:

String or binary data would be truncated.  
The statement has been terminated.

Here is a part of the StackTrace if it helps:

at Litium.Application.Data.LitiumDbContext.SaveChanges(Boolean acceptAllChangesOnSuccess)  
at Litium.Application.Data.Batching.BatchDataImpl.Commit()  
at Litium.Application.Media.FileServiceImpl.Create(File file)

So far other images of the same type have imported successfully. Any tips appreciated!

Litium version: 7.0.0

---

<div class="post-metadata">

**Author:** ![steve.redstorm](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/steve.redstorm/32/14_2.png) [@steve.redstorm](https://forum.litium.com/u/steve.redstorm)\
**Post date:** [November 16, 2018, 8:58am UTC](https://forum.litium.com/t/integrationkit-import-of-media-fails-with-exception/368/2 "2018-11-16T08:58:23Z")

</div>

Is it possible to change the image-name to a shorter and try?

---

<div class="post-metadata">

**Author:** ![StephenM](https://avatars.discourse-cdn.com/v4/letter/s/4da419/32.png) [@StephenM](https://forum.litium.com/u/StephenM)\
**Post date:** [November 16, 2018, 9:16am UTC](https://forum.litium.com/t/integrationkit-import-of-media-fails-with-exception/368/3 "2018-11-16T09:16:59Z")

</div>

The name of the file appears to not matter, but the Id was the issue. I see in the database that this field is type nvarchar(100) so the length of the File Id is clearly the issue.

I’ve just been setting the Id to the filename without the extension. Are there any “best practices” regarding setting the Id that others use regarding media file Id’s?

---

<div class="post-metadata">

**Author:** ![steve.redstorm](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/steve.redstorm/32/14_2.png) [@steve.redstorm](https://forum.litium.com/u/steve.redstorm)\
**Post date:** [November 16, 2018, 10:17am UTC](https://forum.litium.com/t/integrationkit-import-of-media-fails-with-exception/368/4 "2018-11-16T10:17:41Z")

</div>

You can set product/variant id and with “\_A” or “\_B”… suffix if more then one image.

---

<div class="post-metadata">

**Author:** ![patric.forsgard](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/patric.forsgard/32/10_2.png) [@patric.forsgard](https://forum.litium.com/u/patric.forsgard)\
**Post date:** [November 16, 2018, 10:59am UTC](https://forum.litium.com/t/integrationkit-import-of-media-fails-with-exception/368/5 "2018-11-16T10:59:50Z")

</div>

> [@StephenM](#):
>
> The name of the file appears to not matter, but the Id was the issue. I see in the database that this field is type nvarchar(100) so the length of the File Id is clearly the issue.

The `File.Id` is not the same as `File.FileName` and the `Id` column that is restricted to 100 characters should be used for an integration id for the file, example the File ID from the external DAM system.

> [@StephenM](#):
>
> I’ve just been setting the Id to the filename without the extension. Are there any “best practices” regarding setting the Id that others use regarding media file Id’s?

The `File.Id` need to be unique over all images, even if they are in different folders. When you upload files in back office the `File.Id` is not set (it is not mandatory) so you can upload a file with the same name in two different folders.

If you do not need to be able to fetch the file by the `Id` then I think you should remove the row `Id = item.FileInfo.Name´ from the MediaImporter.cs in integration kit. The default code will be updated with the same change because the File.Id is not used to see if the file exists or it should be replaced either.
