Media Library API with Azure Blob Storage

Joel Dahlin asked on November 26, 2014 16:14

I am trying to add images to a media library using the API. I have the media library configured to store in Azure Blob Storage.

Has anyone done this? I am using version 7.x.

I've tried this:

MediaFileInfo mfi = new MediaFileInfo(fuImage.PostedFile, 3, "images",500, 500, 500, 1); string imagePath = mfi.FilePath;

The imagePath does get set. However if I look in the media library nothing was added. Also, when I look in Blob storage, it wasn't added in there either.

Any ideas anyone?

Correct Answer

Virgil Carroll answered on November 27, 2014 05:45

Joel,

Are you getting any kind of error returned from the call? I am assuming not. One thought is to check the logs in Azure. I have a feeling its probably more of a write error there than anything Kentico does. I know Azure permissions around things can be quite tricky at times. I would hope the server-based logs would show some kind of error. If not, my last thought is to look through a network monitor tool such as Fiddler to see what is happening. You might pick up whether the push to the Blog storage is actually happening and what kind of an error or message is returned on that.

Just a few thoughts.

Tx, Virgil

0 votesVote for this answer Unmark Correct answer

Recent Answers


Joel Dahlin answered on November 28, 2014 18:56

@Virgil you are right, looks like an Azure permission issue. I was hoping it would be taken care of since I have the CMS.IO configured to use Azure. I'll have to consult with Support on this one.

0 votesVote for this answer Mark as a Correct answer

Virgil Carroll answered on December 4, 2014 00:15

Haha good @Joel. Sorry for the delayed response but I dont get any notifications from the Q & A system. Wish we could

0 votesVote for this answer Mark as a Correct answer

Filip Ligač answered on December 6, 2014 13:03

Hi Joel,

Uploading media files using Kentico API works the same way when utilizing Azure blob storage instead of the standard file system.

Based on your code snippet, you have just created a new MediaFileInfo object but have not registered it in Kentico. What you are missing is calling the following method:

// Create the media file
MediaFileInfoProvider.SetMediaFileInfo(mfi);  
0 votesVote for this answer Mark as a Correct answer

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