Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • glenatron 37 posts 132 karma points
    Dec 19, 2013 @ 03:06
    glenatron
    0

    How does the MediaFileSystem rename files?

    I am working with a custom upload control which is working alright except that when I take my file and save it, the name is changing. That wouldn't matter only I don't know how it is being changed, so I can't save the correct filename as part of my record.

    I can see that spaces are being replaced by "-" but of course I don't know what other changes are likely to occur and looking through the source for PhysicalFileSystem ( which I assume is where the file operations are performed? ) I can't see anything that is performing the name change.

    My code looks like this:

     MediaFileSystem system = FileSystemProviderManager.Current.GetFileSystemProvider<MediaFileSystem>();
     tempPath = String.Format("temp/{0}", UploadBox.FileName);
     system.AddFile(tempPath, UploadBox.FileContent, true);
    

    The problem is that if my tempPath there is temp/ABC 123 DEF.pdf the file that the provider is creating will be called temp/abc-123-def.pdf. All I need to know is whether there is a method I can call to make sure that the record I am storing reflects the actual path that is created or - if there isn't - what changes are made during file path sanitisation.

    Also I am aware that it would be conventional to create media items for this, but these files aren't media items from a structural perspective - in fact they get moved out of Umbraco's reach as part of this process - so I don't think in this case that would be a good approach.

  • Richard Soeteman 4035 posts 12842 karma points MVP
    Dec 19, 2013 @ 06:10
    Richard Soeteman
    0

    I'm not sure but I think it's an internal method on the Mediaservice that handles this. It's great to have this since your original pages can have issues in various browsers. But what you can do is write your own datatype maybe that just stores the file in the format you like. A simple upload control will work I guess?

    Cheers,

    Richard

Please Sign in or register to post replies

Write your reply to:

Draft