Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

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

Vote:
 

Hello!

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!

#120519
Apr 20, 2015 11:04
Vote:
 

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...

#120547
Apr 20, 2015 12:58
Vote:
 

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

#120552
Apr 20, 2015 13:38
Vote:
 

"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.

#120597
Apr 21, 2015 11:28
Vote:
 

Dejan, thanks a lot for the explanation!

#120638
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.