How to get metadata of the actual file being uploaded with FileManager?



When upload files in Edit mode (using FileManager) I can't find any way to read metadata of original file (original file's created date, attributes, etc). What I tried was implementing ICreatingContent where I could get mediadata:

var mediaData = e.Content as MediaData;

but mediaData does not contain any info regarding metadata mentioned above.

Is there any way to read metadata of the actual file being uploaded?

Thanks in advance!

Apr 20, 2015 11:04

You can get a file info of newly created file like this:

private void Instance_CreatingContent(object sender, ContentEventArgs e)
    var mediaData = e.Content as MediaData;
    if (mediaData != null)
        var fileBlob = mediaData.BinaryData as FileBlob;
        if (fileBlob != null)
            var fileInfo = new FileInfo(fileBlob.FilePath);
            // ...

But I'm not sure you can get original file info...

Apr 20, 2015 12:58

Dejan, Thank you for reply! You are rignt, fileInfo variable contains information about file which had already been saved into EPiServer.

Apr 20, 2015 13:38

"The magic" happens in EPiServer.Cms.Shell.UI.Controller.FileUploadController.
If you have dotPeek / ILSpy, you can take a look at UploadAssets and SaveFile methods.

Since uploaded file is posted as HttpPostedFileBase, and HttpPostedFileBase doesn't contain information such as creation date, creator name, etc. you cannot read metadata of original file.

Apr 21, 2015 11:28

Dejan, thanks a lot for the explanation!

Apr 21, 2015 17:40
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.