0

I have a FTP server (IIS) that only allows for certain file types to be uploaded (for example only images). I achieve this with the File Screening feature in the File Server Resource Manager.

This works fine so far, however now I need to only allow standard letters and numbers in filename.

Examples:

test.jpg   [valid]
Test 1.png [valid]
tëßt.png   [invalid]

The File Screening feature doesn't work here.

  1. There are way too many characters that I don't want to allow (so Included Files is no option).
  2. I can't add every character I allow to the Excluded Files since then the extension check no longer works (it will be valid whenever the filename is valid or when the extension matches).

Is there another way I could achieve this?

Trevi Awater
  • 105
  • 7

1 Answers1

1

As a small program based solution you could write a small app which implements a FileSystemWatcher and the Created event.

Then when the event fires you could use a RegEx pattern to make sure the name only contains legal characters, if the match returns false then delete the file. As for providing some feedback to the FTP session I'm not sure if that would be possible at all.

Martyn C
  • 156
  • 2
  • The problem with this is that when a lot of files are uploaded the FileSystemWatcher becomes unreliable (see the remarks section). – Trevi Awater May 18 '16 at 18:05
  • Yep that is very true, you didn't indicate you would be expecting that many changes. How about watching for events using WMI __InstanceCreationEvent watchers for instance? – Martyn C May 18 '16 at 18:08
  • Sounds like a plan, I shall try it out tomorrow :) – Trevi Awater May 18 '16 at 18:10
  • We ended up using the FileSystemWatcher after all (we worked around the unreliable file detects by looping through all the files after the user disconnects). – Trevi Awater May 23 '16 at 07:48
  • 1
    Awesome, glad you got a solution, not 100% what you were after I suspect but hopefully it does a job. – Martyn C May 23 '16 at 07:49