API Questions on Kentico API.
Version 6.x > API > Determining if File Is In the Media Library Database View modes: 
User avatar
Member
Member
Gavin_Paolucci-Kleinow-URMC.Rochester - 11/13/2012 2:01:57 PM
   
Determining if File Is In the Media Library Database
Right now I'm working on a bulk import utility to import files into the Medial Library. The files will already be physically located in the Media Library folders, but will not yet be imported, and there might be other files that are already imported. Because of this, I'm assuming that I need to check if the files are already imported before imported them.

Does anyone know if my assumption correct? If so, does anyone have any ideas of efficient, clean ways of checking if a file is already in the database/has already been imported?
Right now I'm trying to work off of DataRow FileIsNotInDatabase(string fileName) in \CMSModules\MediaLibrary\Controls\MediaLibrary\MediaLibrary.ascx.cs, but it's rather messy. I'm hoping that there's a better way.

Thanks,
-Gavin

User avatar
Member
Member
Gavin_Paolucci-Kleinow-URMC.Rochester - 11/27/2012 1:11:06 PM
   
RE:Determining if File Is In the Media Library Database
robert-tailor.co gave me a solution on how to check if a file is in the media library database in a different thread:
You could use the example given in the API examples in "Site Manager -> Support -> API Examples -> Tools -> Media -> Media File -> Get and update file" as a basis:
// Get the media file
MediaFileInfo foundFile = MediaFileInfoProvider.GetMediaFileInfo(CMSContext.CurrentSiteName, "MyNewFolder/MyNewFile.gif", null);
if (foundFile != null)
{
// Stop! File already exists in library!
}
else
{
// File not found in library. Proceed with import.
}

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 11/28/2012 3:26:38 AM
   
RE:Determining if File Is In the Media Library Database
Hi,

Of course, I'm glad that issue was successfully solved. In API Examples a lof of helpful resources can be found.

Best regards,
Martin Danko