Uploading image file to Media Library via Kentico 9 API

Darren Cole asked on March 7, 2017 23:06

Hi, I'm trying to upload image files to a media library in my Kentico site from an external service. I'm using the Kentico API to do so. I'm using Kentico 9. I followed the example for creating a media library file shown here: https://docs.kentico.com/api9/content-management/media-libraries#Medialibraries-Creatingamedialibraryfile. The relevant kentico database table seems to be updated properly but when I go to the media library via Kentico's Application Dashboard, there is no sign of my uploaded image files. Am I missing something? Please assist.

Recent Answers


Peter Mogilnitski answered on March 8, 2017 06:06 (last edited on March 8, 2017 06:20)

Hi Darren,

I might not be an expert on that one, but from I understood this is a two-step process: file registration (what you've already done via API) and file upload (what you need to do). You have to copy/upload a file to a physical library folder on disc. If you do it vice versa: i.e at first you upload/copy a new file to a library folder it will have the warning icon (brown exclamation sign):

Image Text

It means: A file exists in the library folder on disc but there is no record about it in the DB i.e. in Media_File table. if you click on the warning icon you can create a record.

So just copy/upload your files. They should be stored in <Kentico>\<site name>\media\<library folder>.

0 votesVote for this answer Mark as a Correct answer

Zach Perry answered on March 8, 2017 16:10

You can set the filebinary when creating the media file, to make sure it is stored: mediaFile.FileBinary

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.