public void AddFile(string path, System.IO.Stream stream, bool overrideIfExists)
        {
            this.Logger.Information("AddFile({0}, {1}, {2})", path, stream, overrideIfExists);

            int directory;
            string filename;

            if (UmbracoPath.MediaPathParse(path, out directory, out filename))
            {
                string mimeType = MimeTypeMap.GetMimeType(Path.GetExtension(path));

                using (FilestreamRepository fsr = new FilestreamRepository(this.ConnectionString, this.TableName))
                {
                    bool exists = fsr.FileExists(path);

                    if (overrideIfExists)
                    {
                        if (exists)
                        {
                            fsr.UpdateFile(path, stream, filename, mimeType);
                        }
                        else
                        {
                            fsr.AddFile(directory, path, mimeType, filename, stream);
                        }
                    }
                    else
                    {
                        if (exists)
                        {
                            throw new Exception(String.Format("File '{0}' already exists", path));
                        }
                        else
                        {
                            fsr.AddFile(directory, path, mimeType, filename, stream);
                        }
                    }
                }
            }
        }
        // Sometimes this gets called with n\x where n is directory and x is file, and sometimes
        // it gets called with what I returned from GetUrl
        public bool FileExists(string path)
        {
            this.Logger.Information("FileExists({0})", path);

            path = UmbracoPath.MediaUrlParse(this.HandlerPath, path);

            using (FilestreamRepository fsr = new FilestreamRepository(this.ConnectionString, this.TableName))
            {
                return fsr.FileExists(path);
            }
        }