Corrupted files when storing data to EPiServer Content Repository

While performing a contentRepository.Save(media, SaveAction.Publish) I encountered some errors with corrupted files, unable to open the saved documents from EPi. Attempting to download the files in the File Manager of EPiServer resulted in download errors.

Access was denied to content xxx. The required access level was “Create, Publish”

Turns out I need to specify the minimum access requirements for the save operation for it to be successful (never investigated the greater details behind this), and the following change worked out just fine:

contentRepository.Save(media, SaveAction.Publish, AccessLevel.NoAccess)

AccessLevel.NoAccess defines the minimum access level required to view the files.


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s